mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Run transpec in a few more spec/features/admin specs
This commit is contained in:
@@ -97,7 +97,7 @@ feature 'Customers' do
|
||||
select2_select managed_distributor1.name, from: "shop_id"
|
||||
|
||||
within "tr#c_#{customer1.id}" do
|
||||
find_field('name').value.should eq 'John Doe'
|
||||
expect(find_field('name').value).to eq 'John Doe'
|
||||
|
||||
fill_in "code", with: "new-customer-code"
|
||||
expect(page).to have_css "input[name=code].update-pending"
|
||||
|
||||
@@ -57,7 +57,7 @@ feature 'Enterprises Index' do
|
||||
select d_manager.email, from: 'enterprise_set_collection_attributes_0_owner_id'
|
||||
end
|
||||
click_button "Update"
|
||||
flash_message.should == 'Enterprises updated successfully'
|
||||
expect(flash_message).to eq('Enterprises updated successfully')
|
||||
distributor = Enterprise.find(d.id)
|
||||
expect(distributor.visible).to eq false
|
||||
expect(distributor.sells).to eq 'any'
|
||||
@@ -84,7 +84,7 @@ feature 'Enterprises Index' do
|
||||
select d_manager.email, from: 'enterprise_set_collection_attributes_1_owner_id'
|
||||
end
|
||||
click_button "Update"
|
||||
flash_message.should == 'Update failed'
|
||||
expect(flash_message).to eq('Update failed')
|
||||
expect(page).to have_content "#{d_manager.email} is not permitted to own any more enterprises (limit is 1)."
|
||||
second_distributor.reload
|
||||
expect(second_distributor.owner).to_not eq d_manager
|
||||
|
||||
@@ -14,7 +14,7 @@ feature '
|
||||
click_link 'Enterprises'
|
||||
click_link e.name
|
||||
|
||||
page.should have_content e.name
|
||||
expect(page).to have_content e.name
|
||||
end
|
||||
|
||||
scenario "creating a new enterprise", js: true do
|
||||
@@ -33,8 +33,8 @@ feature '
|
||||
choose "Any"
|
||||
uncheck 'enterprise_is_primary_producer'
|
||||
|
||||
page.should_not have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
|
||||
page.should_not have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
|
||||
expect(page).not_to have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
|
||||
expect(page).not_to have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
|
||||
|
||||
# Filling in details
|
||||
fill_in 'enterprise_name', with: 'Eaterprises'
|
||||
@@ -53,7 +53,7 @@ feature '
|
||||
select2_select 'Victoria', from: 'enterprise_address_attributes_state_id'
|
||||
|
||||
click_button 'Create'
|
||||
flash_message.should == 'Enterprise "Eaterprises" has been successfully created!'
|
||||
expect(flash_message).to eq('Enterprise "Eaterprises" has been successfully created!')
|
||||
end
|
||||
|
||||
scenario "editing an existing enterprise", js: true do
|
||||
@@ -75,7 +75,7 @@ feature '
|
||||
|
||||
fill_in 'enterprise_name', with: 'Eaterprises'
|
||||
fill_in 'enterprise_permalink', with: 'eaterprises-permalink'
|
||||
page.should have_selector '.available'
|
||||
expect(page).to have_selector '.available'
|
||||
choose 'Own'
|
||||
|
||||
# Require login to view shopfront or for checkout
|
||||
@@ -108,35 +108,35 @@ feature '
|
||||
end
|
||||
uncheck 'enterprise_is_primary_producer'
|
||||
choose 'None'
|
||||
page.should_not have_selector "#enterprise_fees"
|
||||
page.should_not have_selector "#payment_methods"
|
||||
page.should_not have_selector "#shipping_methods"
|
||||
expect(page).not_to have_selector "#enterprise_fees"
|
||||
expect(page).not_to have_selector "#payment_methods"
|
||||
expect(page).not_to have_selector "#shipping_methods"
|
||||
check 'enterprise_is_primary_producer'
|
||||
page.should have_selector "#enterprise_fees"
|
||||
page.should_not have_selector "#payment_methods"
|
||||
page.should_not have_selector "#shipping_methods"
|
||||
expect(page).to have_selector "#enterprise_fees"
|
||||
expect(page).not_to have_selector "#payment_methods"
|
||||
expect(page).not_to have_selector "#shipping_methods"
|
||||
uncheck 'enterprise_is_primary_producer'
|
||||
choose 'Own'
|
||||
page.should have_selector "#enterprise_fees"
|
||||
page.should have_selector "#payment_methods"
|
||||
page.should have_selector "#shipping_methods"
|
||||
expect(page).to have_selector "#enterprise_fees"
|
||||
expect(page).to have_selector "#payment_methods"
|
||||
expect(page).to have_selector "#shipping_methods"
|
||||
choose 'Any'
|
||||
page.should have_selector "#enterprise_fees"
|
||||
page.should have_selector "#payment_methods"
|
||||
page.should have_selector "#shipping_methods"
|
||||
expect(page).to have_selector "#enterprise_fees"
|
||||
expect(page).to have_selector "#payment_methods"
|
||||
expect(page).to have_selector "#shipping_methods"
|
||||
|
||||
multi_select2_select eg1.name, from: 'enterprise_group_ids'
|
||||
|
||||
accept_alert do
|
||||
click_link "Payment Methods"
|
||||
end
|
||||
page.should_not have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
|
||||
expect(page).not_to have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
|
||||
check "enterprise_payment_method_ids_#{payment_method.id}"
|
||||
|
||||
accept_alert do
|
||||
click_link "Shipping Methods"
|
||||
end
|
||||
page.should_not have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
|
||||
expect(page).not_to have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
|
||||
check "enterprise_shipping_method_ids_#{shipping_method.id}"
|
||||
|
||||
accept_alert do
|
||||
@@ -173,36 +173,36 @@ feature '
|
||||
end
|
||||
shop_message_input = page.find("text-angular#enterprise_preferred_shopfront_message div[id^='taTextElement']")
|
||||
shop_message_input.native.send_keys('This is my shopfront message.')
|
||||
page.should have_checked_field "enterprise_preferred_shopfront_order_cycle_order_orders_close_at"
|
||||
expect(page).to have_checked_field "enterprise_preferred_shopfront_order_cycle_order_orders_close_at"
|
||||
choose "enterprise_preferred_shopfront_order_cycle_order_orders_open_at"
|
||||
choose "enterprise_enable_subscriptions_true"
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
flash_message.should == 'Enterprise "Eaterprises" has been successfully updated!'
|
||||
page.should have_field 'enterprise_name', with: 'Eaterprises'
|
||||
expect(flash_message).to eq('Enterprise "Eaterprises" has been successfully updated!')
|
||||
expect(page).to have_field 'enterprise_name', with: 'Eaterprises'
|
||||
@enterprise.reload
|
||||
expect(@enterprise.owner).to eq user
|
||||
expect(page).to have_checked_field "enterprise_visible_true"
|
||||
|
||||
click_link "Business Details"
|
||||
page.should have_checked_field "enterprise_charges_sales_tax_true"
|
||||
expect(page).to have_checked_field "enterprise_charges_sales_tax_true"
|
||||
|
||||
click_link "Payment Methods"
|
||||
page.should have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
|
||||
expect(page).to have_checked_field "enterprise_payment_method_ids_#{payment_method.id}"
|
||||
|
||||
click_link "Shipping Methods"
|
||||
page.should have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
|
||||
expect(page).to have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}"
|
||||
|
||||
click_link "Enterprise Fees"
|
||||
page.should have_selector "td", text: enterprise_fee.name
|
||||
expect(page).to have_selector "td", text: enterprise_fee.name
|
||||
|
||||
click_link "About"
|
||||
page.should have_content 'This is an interesting long description'
|
||||
expect(page).to have_content 'This is an interesting long description'
|
||||
|
||||
click_link "Shop Preferences"
|
||||
page.should have_content 'This is my shopfront message.'
|
||||
page.should have_checked_field "enterprise_preferred_shopfront_order_cycle_order_orders_open_at"
|
||||
expect(page).to have_content 'This is my shopfront message.'
|
||||
expect(page).to have_checked_field "enterprise_preferred_shopfront_order_cycle_order_orders_open_at"
|
||||
expect(page).to have_checked_field "enterprise_require_login_true"
|
||||
expect(page).to have_checked_field "enterprise_enable_subscriptions_true"
|
||||
|
||||
@@ -232,9 +232,9 @@ feature '
|
||||
expect(current_path).to eq main_app.admin_enterprise_producer_properties_path(s)
|
||||
|
||||
# And the producer should have the property
|
||||
s.producer_properties(true).count.should == 1
|
||||
s.producer_properties.first.property.presentation.should == "Certified Organic"
|
||||
s.producer_properties.first.value.should == "NASAA 12345"
|
||||
expect(s.producer_properties(true).count).to eq(1)
|
||||
expect(s.producer_properties.first.property.presentation).to eq("Certified Organic")
|
||||
expect(s.producer_properties.first.value).to eq("NASAA 12345")
|
||||
end
|
||||
|
||||
it "updates producer properties" do
|
||||
@@ -255,9 +255,9 @@ feature '
|
||||
expect(current_path).to eq main_app.admin_enterprise_producer_properties_path(s)
|
||||
|
||||
# And the property should be updated
|
||||
s.producer_properties(true).count.should == 1
|
||||
s.producer_properties.first.property.presentation.should == "Biodynamic"
|
||||
s.producer_properties.first.value.should == "Shininess"
|
||||
expect(s.producer_properties(true).count).to eq(1)
|
||||
expect(s.producer_properties.first.property.presentation).to eq("Biodynamic")
|
||||
expect(s.producer_properties.first.value).to eq("Shininess")
|
||||
end
|
||||
|
||||
it "removes producer properties", js: true do
|
||||
@@ -270,14 +270,14 @@ feature '
|
||||
visit main_app.admin_enterprise_producer_properties_path(s)
|
||||
|
||||
# And I remove the property
|
||||
page.should have_field 'enterprise_producer_properties_attributes_0_property_name', with: 'Certified Organic'
|
||||
expect(page).to have_field 'enterprise_producer_properties_attributes_0_property_name', with: 'Certified Organic'
|
||||
within("#spree_producer_property_#{pp.id}") { page.find('a.remove_fields').click }
|
||||
click_button 'Update'
|
||||
|
||||
# Then the property should have been removed
|
||||
expect(current_path).to eq main_app.admin_enterprise_producer_properties_path(s)
|
||||
page.should_not have_field 'enterprise_producer_properties_attributes_0_property_name', with: 'Certified Organic'
|
||||
s.producer_properties(true).should be_empty
|
||||
expect(page).not_to have_field 'enterprise_producer_properties_attributes_0_property_name', with: 'Certified Organic'
|
||||
expect(s.producer_properties(true)).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
@@ -333,8 +333,8 @@ feature '
|
||||
|
||||
visit admin_enterprises_path
|
||||
|
||||
page.should have_content supplier1.name
|
||||
page.should have_content distributor1.name
|
||||
expect(page).to have_content supplier1.name
|
||||
expect(page).to have_content distributor1.name
|
||||
|
||||
within 'li#new_product_link' do
|
||||
expect(page).to have_link 'New Enterprise', href: '#'
|
||||
@@ -363,12 +363,12 @@ feature '
|
||||
click_button 'Create'
|
||||
|
||||
# Then it should be created
|
||||
page.should have_content 'Enterprise "zzz" has been successfully created!'
|
||||
expect(page).to have_content 'Enterprise "zzz" has been successfully created!'
|
||||
enterprise = Enterprise.last
|
||||
enterprise.name.should == 'zzz'
|
||||
expect(enterprise.name).to eq('zzz')
|
||||
|
||||
# And I should be managing it
|
||||
Enterprise.managed_by(enterprise_user).should include enterprise
|
||||
expect(Enterprise.managed_by(enterprise_user)).to include enterprise
|
||||
expect(enterprise.contact).to eq enterprise.owner
|
||||
end
|
||||
|
||||
@@ -398,8 +398,8 @@ feature '
|
||||
page.evaluate_script("angular.element(enterprise_form).scope().setFormDirty()")
|
||||
click_button 'Update'
|
||||
|
||||
flash_message.should == 'Enterprise "Eaterprises" has been successfully updated!'
|
||||
distributor1.reload.name.should == 'Eaterprises'
|
||||
expect(flash_message).to eq('Enterprise "Eaterprises" has been successfully updated!')
|
||||
expect(distributor1.reload.name).to eq('Eaterprises')
|
||||
end
|
||||
|
||||
describe "enterprises I have edit permission for, but do not manage" do
|
||||
@@ -414,8 +414,8 @@ feature '
|
||||
page.evaluate_script("angular.element(enterprise_form).scope().setFormDirty()")
|
||||
click_button 'Update'
|
||||
|
||||
flash_message.should == 'Enterprise "Eaterprises" has been successfully updated!'
|
||||
distributor3.reload.name.should == 'Eaterprises'
|
||||
expect(flash_message).to eq('Enterprise "Eaterprises" has been successfully updated!')
|
||||
expect(distributor3.reload.name).to eq('Eaterprises')
|
||||
end
|
||||
|
||||
it "does not show links to manage shipping methods, payment methods or enterprise fees on the edit page" do
|
||||
@@ -423,9 +423,9 @@ feature '
|
||||
within("tbody#e_#{distributor3.id}") { click_link 'Settings' }
|
||||
|
||||
within(".side_menu") do
|
||||
page.should_not have_link 'Shipping Methods'
|
||||
page.should_not have_link 'Payment Methods'
|
||||
page.should_not have_link 'Enterprise Fees'
|
||||
expect(page).not_to have_link 'Shipping Methods'
|
||||
expect(page).not_to have_link 'Payment Methods'
|
||||
expect(page).not_to have_link 'Enterprise Fees'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -448,7 +448,7 @@ feature '
|
||||
page.evaluate_script("angular.element(enterprise_form).scope().setFormDirty()")
|
||||
click_button 'Update'
|
||||
|
||||
supplier1.producer_properties(true).count.should == 1
|
||||
expect(supplier1.producer_properties(true).count).to eq(1)
|
||||
|
||||
# -- Destroy
|
||||
pp = supplier1.producer_properties.first
|
||||
@@ -466,7 +466,7 @@ feature '
|
||||
click_button 'Update'
|
||||
|
||||
expect(page).to have_content 'Enterprise "First Supplier" has been successfully updated!'
|
||||
supplier1.producer_properties(true).should be_empty
|
||||
expect(supplier1.producer_properties(true)).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ feature 'External services' do
|
||||
fill_in 'bugherd_api_key', with: 'abc123'
|
||||
click_button 'Update'
|
||||
|
||||
page.should have_content 'General Settings has been successfully updated!'
|
||||
expect(page).to have_content 'General Settings has been successfully updated!'
|
||||
expect(Spree::Config.bugherd_api_key).to eq 'abc123'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,13 +38,13 @@ feature '
|
||||
expect(all("#listing_order_cycles tr td:first-child input").map(&:value)).to eq order_cycle_names
|
||||
|
||||
# And the rows should have the correct classes
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}.undated"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}.open"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}.open"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}.upcoming"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc4.id}.upcoming"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc5.id}.closed"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc6.id}.closed"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}.undated"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}.open"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}.open"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}.upcoming"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc4.id}.upcoming"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc5.id}.closed"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc6.id}.closed"
|
||||
|
||||
toggle_columns "Producers", "Shops"
|
||||
|
||||
@@ -57,59 +57,59 @@ feature '
|
||||
expect(page).to have_content oc1.coordinator.name
|
||||
|
||||
# And I should see the suppliers and distributors
|
||||
oc1.suppliers.each { |s| page.should have_content s.name }
|
||||
oc1.distributors.each { |d| page.should have_content d.name }
|
||||
oc1.suppliers.each { |s| expect(page).to have_content s.name }
|
||||
oc1.distributors.each { |d| expect(page).to have_content d.name }
|
||||
|
||||
# And I should see the number of variants
|
||||
page.should have_selector 'td.products', text: '2 variants'
|
||||
expect(page).to have_selector 'td.products', text: '2 variants'
|
||||
end
|
||||
|
||||
# I can load more order_cycles
|
||||
page.should have_no_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}"
|
||||
expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}"
|
||||
click_button "Show 30 more days"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}"
|
||||
|
||||
# I can filter order cycle by involved enterprises
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
select2_select oc1.suppliers.first.name, from: "involving_filter"
|
||||
page.should have_no_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_no_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
select2_select "Any Enterprise", from: "involving_filter"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
|
||||
# I can filter order cycles by name
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
fill_in "query", with: oc0.name
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_no_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_no_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
fill_in "query", with: ''
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
|
||||
# I can filter order cycle by schedule
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}"
|
||||
select2_select schedule1.name, from: "schedule_filter"
|
||||
page.should have_no_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_no_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}"
|
||||
expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}"
|
||||
select2_select 'Any Schedule', from: "schedule_filter"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}"
|
||||
expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}"
|
||||
|
||||
# Attempting to edit dates of an open order cycle with active subscriptions
|
||||
find("#oc#{oc1.id}_orders_open_at").click
|
||||
@@ -191,8 +191,8 @@ feature '
|
||||
select 'Coord fee', from: 'order_cycle_coordinator_fee_0_id'
|
||||
|
||||
# I should not be able to add a blank supplier
|
||||
page.should have_select 'new_supplier_id', selected: ''
|
||||
page.should have_button 'Add supplier', disabled: true
|
||||
expect(page).to have_select 'new_supplier_id', selected: ''
|
||||
expect(page).to have_button 'Add supplier', disabled: true
|
||||
|
||||
# And I add a supplier and some products
|
||||
select 'My supplier', from: 'new_supplier_id'
|
||||
@@ -203,9 +203,9 @@ feature '
|
||||
check "order_cycle_incoming_exchange_0_variants_#{v2.id}"
|
||||
|
||||
# I should not be able to re-add the supplier
|
||||
page.should_not have_select 'new_supplier_id', with_options: ['My supplier']
|
||||
page.should have_button 'Add supplier', disabled: true
|
||||
page.all("td.supplier_name").map(&:text).should == ['My supplier']
|
||||
expect(page).not_to have_select 'new_supplier_id', with_options: ['My supplier']
|
||||
expect(page).to have_button 'Add supplier', disabled: true
|
||||
expect(page.all("td.supplier_name").map(&:text)).to eq(['My supplier'])
|
||||
|
||||
# And I add a supplier fee
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
@@ -237,7 +237,7 @@ feature '
|
||||
click_button 'Create'
|
||||
|
||||
# Then my order cycle should have been created
|
||||
page.should have_content 'Your order cycle has been created.'
|
||||
expect(page).to have_content 'Your order cycle has been created.'
|
||||
|
||||
oc = OrderCycle.last
|
||||
|
||||
@@ -248,26 +248,26 @@ feature '
|
||||
expect(page).to have_input "oc#{oc.id}[orders_close_at]", value: order_cycle_closing_time
|
||||
expect(page).to have_content "My coordinator"
|
||||
|
||||
page.should have_selector 'td.producers', text: 'My supplier'
|
||||
page.should have_selector 'td.shops', text: 'My distributor'
|
||||
expect(page).to have_selector 'td.producers', text: 'My supplier'
|
||||
expect(page).to have_selector 'td.shops', text: 'My distributor'
|
||||
|
||||
# And it should have some fees
|
||||
oc.exchanges.incoming.first.enterprise_fees.should == [supplier_fee]
|
||||
oc.coordinator_fees.should == [coordinator_fee]
|
||||
oc.exchanges.outgoing.first.enterprise_fees.should == [distributor_fee]
|
||||
expect(oc.exchanges.incoming.first.enterprise_fees).to eq([supplier_fee])
|
||||
expect(oc.coordinator_fees).to eq([coordinator_fee])
|
||||
expect(oc.exchanges.outgoing.first.enterprise_fees).to eq([distributor_fee])
|
||||
|
||||
# And it should have some variants selected
|
||||
oc.exchanges.first.variants.count.should == 2
|
||||
oc.exchanges.last.variants.count.should == 2
|
||||
expect(oc.exchanges.first.variants.count).to eq(2)
|
||||
expect(oc.exchanges.last.variants.count).to eq(2)
|
||||
|
||||
# And my receival and pickup time and instructions should have been saved
|
||||
exchange = oc.exchanges.incoming.first
|
||||
exchange.receival_instructions.should == 'receival instructions'
|
||||
expect(exchange.receival_instructions).to eq('receival instructions')
|
||||
|
||||
exchange = oc.exchanges.outgoing.first
|
||||
exchange.pickup_time.should == 'pickup time'
|
||||
exchange.pickup_instructions.should == 'pickup instructions'
|
||||
exchange.tag_list.should == ['wholesale']
|
||||
expect(exchange.pickup_time).to eq('pickup time')
|
||||
expect(exchange.pickup_instructions).to eq('pickup instructions')
|
||||
expect(exchange.tag_list).to eq(['wholesale'])
|
||||
end
|
||||
|
||||
scenario "updating an order cycle", js: true do
|
||||
@@ -326,7 +326,7 @@ feature '
|
||||
click_button 'Add supplier'
|
||||
page.all("table.exchanges tr.supplier td.products").each(&:click)
|
||||
|
||||
page.should have_selector "#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true
|
||||
expect(page).to have_selector "#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true
|
||||
page.find("#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true).click # uncheck (with visible:true filter)
|
||||
check "order_cycle_incoming_exchange_2_variants_#{v1.id}"
|
||||
check "order_cycle_incoming_exchange_2_variants_#{v2.id}"
|
||||
@@ -377,7 +377,7 @@ feature '
|
||||
click_button 'Update and Close'
|
||||
|
||||
# Then my order cycle should have been updated
|
||||
page.should have_content 'Your order cycle has been updated.'
|
||||
expect(page).to have_content 'Your order cycle has been updated.'
|
||||
|
||||
oc = OrderCycle.last
|
||||
|
||||
@@ -388,28 +388,28 @@ feature '
|
||||
expect(page).to have_input "oc#{oc.id}[orders_close_at]", value: order_cycle_closing_time
|
||||
expect(page).to have_content coordinator.name
|
||||
|
||||
page.should have_selector 'td.producers', text: 'My supplier'
|
||||
page.should have_selector 'td.shops', text: 'My distributor'
|
||||
expect(page).to have_selector 'td.producers', text: 'My supplier'
|
||||
expect(page).to have_selector 'td.shops', text: 'My distributor'
|
||||
|
||||
# And my coordinator fees should have been configured
|
||||
oc.coordinator_fee_ids.should match_array [coordinator_fee1.id, coordinator_fee2.id]
|
||||
expect(oc.coordinator_fee_ids).to match_array [coordinator_fee1.id, coordinator_fee2.id]
|
||||
|
||||
# And my supplier fees should have been configured
|
||||
oc.exchanges.incoming.last.enterprise_fee_ids.should == [supplier_fee2.id]
|
||||
expect(oc.exchanges.incoming.last.enterprise_fee_ids).to eq([supplier_fee2.id])
|
||||
|
||||
# And my distributor fees should have been configured
|
||||
oc.exchanges.outgoing.last.enterprise_fee_ids.should == [distributor_fee2.id]
|
||||
expect(oc.exchanges.outgoing.last.enterprise_fee_ids).to eq([distributor_fee2.id])
|
||||
|
||||
# And my tags should have been save
|
||||
oc.exchanges.outgoing.last.tag_list.should == ['wholesale']
|
||||
expect(oc.exchanges.outgoing.last.tag_list).to eq(['wholesale'])
|
||||
|
||||
# And it should have some variants selected
|
||||
selected_initial_variants = initial_variants.take initial_variants.size - 1
|
||||
oc.variants.map(&:id).should match_array((selected_initial_variants.map(&:id) + [v1.id, v2.id]))
|
||||
expect(oc.variants.map(&:id)).to match_array((selected_initial_variants.map(&:id) + [v1.id, v2.id]))
|
||||
|
||||
# And the collection details should have been updated
|
||||
oc.exchanges.where(pickup_time: 'New time 0', pickup_instructions: 'New instructions 0').should be_present
|
||||
oc.exchanges.where(pickup_time: 'New time 1', pickup_instructions: 'New instructions 1').should be_present
|
||||
expect(oc.exchanges.where(pickup_time: 'New time 0', pickup_instructions: 'New instructions 0')).to be_present
|
||||
expect(oc.exchanges.where(pickup_time: 'New time 1', pickup_instructions: 'New instructions 1')).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
@@ -428,64 +428,64 @@ feature '
|
||||
wait_for_edit_form_to_load_order_cycle(oc)
|
||||
|
||||
# Then I should see the basic settings
|
||||
page.find('#order_cycle_name').value.should == oc.name
|
||||
page.find('#order_cycle_orders_open_at').value.should == oc.orders_open_at.to_s
|
||||
page.find('#order_cycle_orders_close_at').value.should == oc.orders_close_at.to_s
|
||||
page.should have_content "COORDINATOR #{oc.coordinator.name}"
|
||||
expect(page.find('#order_cycle_name').value).to eq(oc.name)
|
||||
expect(page.find('#order_cycle_orders_open_at').value).to eq(oc.orders_open_at.to_s)
|
||||
expect(page.find('#order_cycle_orders_close_at').value).to eq(oc.orders_close_at.to_s)
|
||||
expect(page).to have_content "COORDINATOR #{oc.coordinator.name}"
|
||||
|
||||
# And I should see the suppliers
|
||||
page.should have_selector 'td.supplier_name', text: oc.suppliers.first.name
|
||||
page.should have_selector 'td.supplier_name', text: oc.suppliers.last.name
|
||||
expect(page).to have_selector 'td.supplier_name', text: oc.suppliers.first.name
|
||||
expect(page).to have_selector 'td.supplier_name', text: oc.suppliers.last.name
|
||||
|
||||
page.should have_field 'order_cycle_incoming_exchange_0_receival_instructions', with: 'instructions 0'
|
||||
page.should have_field 'order_cycle_incoming_exchange_1_receival_instructions', with: 'instructions 1'
|
||||
expect(page).to have_field 'order_cycle_incoming_exchange_0_receival_instructions', with: 'instructions 0'
|
||||
expect(page).to have_field 'order_cycle_incoming_exchange_1_receival_instructions', with: 'instructions 1'
|
||||
|
||||
# And the suppliers should have products
|
||||
page.all('table.exchanges tbody tr.supplier').each_with_index do |row, i|
|
||||
row.find('td.products').click
|
||||
|
||||
products_panel = page.all('table.exchanges tr.panel-row .exchange-supplied-products').select(&:visible?).first
|
||||
products_panel.should have_selector "input[name='order_cycle_incoming_exchange_#{i}_select_all_variants']"
|
||||
expect(products_panel).to have_selector "input[name='order_cycle_incoming_exchange_#{i}_select_all_variants']"
|
||||
|
||||
row.find('td.products').click
|
||||
end
|
||||
|
||||
# And the suppliers should have fees
|
||||
supplier = oc.suppliers.min_by(&:name)
|
||||
page.should have_select 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_id', selected: supplier.name
|
||||
page.should have_select 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_fee_id', selected: supplier.enterprise_fees.first.name
|
||||
expect(page).to have_select 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_id', selected: supplier.name
|
||||
expect(page).to have_select 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_fee_id', selected: supplier.enterprise_fees.first.name
|
||||
|
||||
supplier = oc.suppliers.max_by(&:name)
|
||||
page.should have_select 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_id', selected: supplier.name
|
||||
page.should have_select 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_fee_id', selected: supplier.enterprise_fees.first.name
|
||||
expect(page).to have_select 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_id', selected: supplier.name
|
||||
expect(page).to have_select 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_fee_id', selected: supplier.enterprise_fees.first.name
|
||||
|
||||
# And I should see the distributors
|
||||
page.should have_selector 'td.distributor_name', text: oc.distributors.first.name
|
||||
page.should have_selector 'td.distributor_name', text: oc.distributors.last.name
|
||||
expect(page).to have_selector 'td.distributor_name', text: oc.distributors.first.name
|
||||
expect(page).to have_selector 'td.distributor_name', text: oc.distributors.last.name
|
||||
|
||||
page.should have_field 'order_cycle_outgoing_exchange_0_pickup_time', with: 'time 0'
|
||||
page.should have_field 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'instructions 0'
|
||||
page.should have_field 'order_cycle_outgoing_exchange_1_pickup_time', with: 'time 1'
|
||||
page.should have_field 'order_cycle_outgoing_exchange_1_pickup_instructions', with: 'instructions 1'
|
||||
expect(page).to have_field 'order_cycle_outgoing_exchange_0_pickup_time', with: 'time 0'
|
||||
expect(page).to have_field 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'instructions 0'
|
||||
expect(page).to have_field 'order_cycle_outgoing_exchange_1_pickup_time', with: 'time 1'
|
||||
expect(page).to have_field 'order_cycle_outgoing_exchange_1_pickup_instructions', with: 'instructions 1'
|
||||
|
||||
# And the distributors should have products
|
||||
page.all('table.exchanges tbody tr.distributor').each_with_index do |row, i|
|
||||
row.find('td.products').click
|
||||
|
||||
products_panel = page.all('table.exchanges tr.panel-row .exchange-distributed-products').select(&:visible?).first
|
||||
products_panel.should have_selector "input[name='order_cycle_outgoing_exchange_#{i}_select_all_variants']"
|
||||
expect(products_panel).to have_selector "input[name='order_cycle_outgoing_exchange_#{i}_select_all_variants']"
|
||||
|
||||
row.find('td.products').click
|
||||
end
|
||||
|
||||
# And the distributors should have fees
|
||||
distributor = oc.distributors.min_by(&:id)
|
||||
page.should have_select 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_id', selected: distributor.name
|
||||
page.should have_select 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_fee_id', selected: distributor.enterprise_fees.first.name
|
||||
expect(page).to have_select 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_id', selected: distributor.name
|
||||
expect(page).to have_select 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_fee_id', selected: distributor.enterprise_fees.first.name
|
||||
|
||||
distributor = oc.distributors.max_by(&:id)
|
||||
page.should have_select 'order_cycle_outgoing_exchange_1_enterprise_fees_0_enterprise_id', selected: distributor.name
|
||||
page.should have_select 'order_cycle_outgoing_exchange_1_enterprise_fees_0_enterprise_fee_id', selected: distributor.enterprise_fees.first.name
|
||||
expect(page).to have_select 'order_cycle_outgoing_exchange_1_enterprise_fees_0_enterprise_id', selected: distributor.name
|
||||
expect(page).to have_select 'order_cycle_outgoing_exchange_1_enterprise_fees_0_enterprise_fee_id', selected: distributor.enterprise_fees.first.name
|
||||
end
|
||||
|
||||
scenario "editing an order cycle with an exchange between the same enterprise" do
|
||||
@@ -500,13 +500,13 @@ feature '
|
||||
# When I edit the first order cycle, the exchange should appear as incoming
|
||||
quick_login_as_admin
|
||||
visit edit_admin_order_cycle_path(oc_incoming)
|
||||
page.should have_selector 'table.exchanges tr.supplier'
|
||||
page.should_not have_selector 'table.exchanges tr.distributor'
|
||||
expect(page).to have_selector 'table.exchanges tr.supplier'
|
||||
expect(page).not_to have_selector 'table.exchanges tr.distributor'
|
||||
|
||||
# And when I edit the second order cycle, the exchange should appear as outgoing
|
||||
visit edit_admin_order_cycle_path(oc_outgoing)
|
||||
page.should have_selector 'table.exchanges tr.distributor'
|
||||
page.should_not have_selector 'table.exchanges tr.supplier'
|
||||
expect(page).to have_selector 'table.exchanges tr.distributor'
|
||||
expect(page).not_to have_selector 'table.exchanges tr.supplier'
|
||||
end
|
||||
|
||||
scenario "updating many order cycle opening/closing times at once", js: true do
|
||||
@@ -598,7 +598,7 @@ feature '
|
||||
d = create(:distributor_enterprise)
|
||||
oc = create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.master])
|
||||
exchange_ids = oc.exchanges.pluck :id
|
||||
ExchangeVariant.where(exchange_id: exchange_ids, variant_id: p.master.id).should_not be_empty
|
||||
expect(ExchangeVariant.where(exchange_id: exchange_ids, variant_id: p.master.id)).not_to be_empty
|
||||
|
||||
# When I go to the order cycle page and remove the obsolete master
|
||||
quick_login_as_admin
|
||||
@@ -608,8 +608,8 @@ feature '
|
||||
click_button "Update"
|
||||
|
||||
# Then the master variant should have been removed from all exchanges
|
||||
page.should have_content "Your order cycle has been updated."
|
||||
ExchangeVariant.where(exchange_id: exchange_ids, variant_id: p.master.id).should be_empty
|
||||
expect(page).to have_content "Your order cycle has been updated."
|
||||
expect(ExchangeVariant.where(exchange_id: exchange_ids, variant_id: p.master.id)).to be_empty
|
||||
end
|
||||
|
||||
describe "ensuring that hubs in order cycles have valid shipping and payment methods" do
|
||||
@@ -619,13 +619,13 @@ feature '
|
||||
|
||||
it "displays a warning on the dashboard" do
|
||||
login_to_admin_section
|
||||
page.should have_content "The hub #{hub.name} is listed in an active order cycle, but does not have valid shipping and payment methods. Until you set these up, customers will not be able to shop at this hub."
|
||||
expect(page).to have_content "The hub #{hub.name} is listed in an active order cycle, but does not have valid shipping and payment methods. Until you set these up, customers will not be able to shop at this hub."
|
||||
end
|
||||
|
||||
it "displays a warning on the order cycles screen" do
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
page.should have_content "The hub #{hub.name} is listed in an active order cycle, but does not have valid shipping and payment methods. Until you set these up, customers will not be able to shop at this hub."
|
||||
expect(page).to have_content "The hub #{hub.name} is listed in an active order cycle, but does not have valid shipping and payment methods. Until you set these up, customers will not be able to shop at this hub."
|
||||
end
|
||||
end
|
||||
|
||||
@@ -635,7 +635,7 @@ feature '
|
||||
|
||||
it "does not display the warning on the dashboard" do
|
||||
login_to_admin_section
|
||||
page.should_not have_content "does not have valid shipping and payment methods"
|
||||
expect(page).not_to have_content "does not have valid shipping and payment methods"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -693,10 +693,10 @@ feature '
|
||||
toggle_columns "Producers", "Shops"
|
||||
|
||||
# The order cycle should show all enterprises in the order cycle
|
||||
page.should have_selector 'td.producers', text: supplier_managed.name
|
||||
page.should have_selector 'td.shops', text: distributor_managed.name
|
||||
page.should have_selector 'td.producers', text: supplier_unmanaged.name
|
||||
page.should have_selector 'td.shops', text: distributor_unmanaged.name
|
||||
expect(page).to have_selector 'td.producers', text: supplier_managed.name
|
||||
expect(page).to have_selector 'td.shops', text: distributor_managed.name
|
||||
expect(page).to have_selector 'td.producers', text: supplier_unmanaged.name
|
||||
expect(page).to have_selector 'td.shops', text: distributor_unmanaged.name
|
||||
end
|
||||
|
||||
scenario "creating a new order cycle" do
|
||||
@@ -732,11 +732,11 @@ feature '
|
||||
|
||||
# Should only have suppliers / distributors listed which the user is managing or
|
||||
# has E2E permission to add products to order cycles
|
||||
page.should_not have_select 'new_supplier_id', with_options: [supplier_unmanaged.name]
|
||||
page.should_not have_select 'new_distributor_id', with_options: [distributor_unmanaged.name]
|
||||
expect(page).not_to have_select 'new_supplier_id', with_options: [supplier_unmanaged.name]
|
||||
expect(page).not_to have_select 'new_distributor_id', with_options: [distributor_unmanaged.name]
|
||||
|
||||
[distributor_unmanaged.name, supplier_managed.name, supplier_unmanaged.name].each do |enterprise_name|
|
||||
page.should_not have_select 'order_cycle_coordinator_id', with_options: [enterprise_name]
|
||||
expect(page).not_to have_select 'order_cycle_coordinator_id', with_options: [enterprise_name]
|
||||
end
|
||||
|
||||
page.find("table.exchanges tr.distributor-#{distributor_managed.id} td.tags").click
|
||||
@@ -746,14 +746,14 @@ feature '
|
||||
|
||||
click_button 'Create'
|
||||
|
||||
flash_message.should == "Your order cycle has been created."
|
||||
expect(flash_message).to eq("Your order cycle has been created.")
|
||||
order_cycle = OrderCycle.find_by_name('My order cycle')
|
||||
order_cycle.suppliers.should match_array [supplier_managed, supplier_permitted]
|
||||
order_cycle.coordinator.should == distributor_managed
|
||||
order_cycle.distributors.should match_array [distributor_managed, distributor_permitted]
|
||||
order_cycle.schedules.should == [schedule]
|
||||
expect(order_cycle.suppliers).to match_array [supplier_managed, supplier_permitted]
|
||||
expect(order_cycle.coordinator).to eq(distributor_managed)
|
||||
expect(order_cycle.distributors).to match_array [distributor_managed, distributor_permitted]
|
||||
expect(order_cycle.schedules).to eq([schedule])
|
||||
exchange = order_cycle.exchanges.outgoing.to_enterprise(distributor_managed).first
|
||||
exchange.tag_list.should == ["wholesale"]
|
||||
expect(exchange.tag_list).to eq(["wholesale"])
|
||||
end
|
||||
|
||||
scenario "editing an order cycle we can see (and for now, edit) all exchanges in the order cycle" do
|
||||
@@ -781,12 +781,12 @@ feature '
|
||||
|
||||
# When I save, then those exchanges should remain
|
||||
click_button 'Update'
|
||||
page.should have_content "Your order cycle has been updated."
|
||||
expect(page).to have_content "Your order cycle has been updated."
|
||||
|
||||
oc.reload
|
||||
oc.suppliers.should match_array [supplier_managed, supplier_permitted, supplier_unmanaged]
|
||||
oc.coordinator.should == distributor_managed
|
||||
oc.distributors.should match_array [distributor_managed, distributor_permitted, distributor_unmanaged]
|
||||
expect(oc.suppliers).to match_array [supplier_managed, supplier_permitted, supplier_unmanaged]
|
||||
expect(oc.coordinator).to eq(distributor_managed)
|
||||
expect(oc.distributors).to match_array [distributor_managed, distributor_permitted, distributor_unmanaged]
|
||||
end
|
||||
|
||||
scenario "editing an order cycle" do
|
||||
@@ -806,13 +806,13 @@ feature '
|
||||
click_button 'Update'
|
||||
|
||||
# Then the exchanges should be removed
|
||||
page.should have_content "Your order cycle has been updated."
|
||||
expect(page).to have_content "Your order cycle has been updated."
|
||||
|
||||
oc.reload
|
||||
oc.suppliers.should == [supplier_unmanaged]
|
||||
oc.coordinator.should == distributor_managed
|
||||
oc.distributors.should == [distributor_unmanaged]
|
||||
oc.schedules.should == [schedule]
|
||||
expect(oc.suppliers).to eq([supplier_unmanaged])
|
||||
expect(oc.coordinator).to eq(distributor_managed)
|
||||
expect(oc.distributors).to eq([distributor_unmanaged])
|
||||
expect(oc.schedules).to eq([schedule])
|
||||
end
|
||||
|
||||
scenario "cloning an order cycle" do
|
||||
@@ -826,7 +826,7 @@ feature '
|
||||
|
||||
# Then I should have clone of the order cycle
|
||||
occ = OrderCycle.last
|
||||
occ.name.should == "COPY OF #{oc.name}"
|
||||
expect(occ.name).to eq("COPY OF #{oc.name}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -882,16 +882,16 @@ feature '
|
||||
# I should be able to see but not toggle v2, because I don't have permission
|
||||
expect(page).to have_checked_field "order_cycle_outgoing_exchange_0_variants_#{v2.id}", disabled: true
|
||||
|
||||
page.should_not have_selector "table.exchanges tr.distributor-#{distributor_managed.id} td.tags"
|
||||
expect(page).not_to have_selector "table.exchanges tr.distributor-#{distributor_managed.id} td.tags"
|
||||
|
||||
# When I save, any exchanges that I can't manage remain
|
||||
click_button 'Update'
|
||||
page.should have_content "Your order cycle has been updated."
|
||||
expect(page).to have_content "Your order cycle has been updated."
|
||||
|
||||
oc.reload
|
||||
oc.suppliers.should match_array [supplier_managed, supplier_permitted, supplier_unmanaged]
|
||||
oc.coordinator.should == distributor_managed
|
||||
oc.distributors.should match_array [distributor_managed, distributor_permitted, distributor_unmanaged]
|
||||
expect(oc.suppliers).to match_array [supplier_managed, supplier_permitted, supplier_unmanaged]
|
||||
expect(oc.coordinator).to eq(distributor_managed)
|
||||
expect(oc.distributors).to match_array [distributor_managed, distributor_permitted, distributor_unmanaged]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -947,16 +947,16 @@ feature '
|
||||
# I should be able to see but not toggle v2, because I don't have permission
|
||||
expect(page).to have_checked_field "order_cycle_incoming_exchange_0_variants_#{v2.id}", disabled: true
|
||||
|
||||
page.should have_selector "table.exchanges tr.distributor-#{my_distributor.id} td.tags"
|
||||
expect(page).to have_selector "table.exchanges tr.distributor-#{my_distributor.id} td.tags"
|
||||
|
||||
# When I save, any exchange that I can't manage remains
|
||||
click_button 'Update'
|
||||
page.should have_content "Your order cycle has been updated."
|
||||
expect(page).to have_content "Your order cycle has been updated."
|
||||
|
||||
oc.reload
|
||||
oc.suppliers.should match_array [supplier_managed, supplier_permitted, supplier_unmanaged]
|
||||
oc.coordinator.should == distributor_managed
|
||||
oc.distributors.should match_array [my_distributor, distributor_managed, distributor_permitted, distributor_unmanaged]
|
||||
expect(oc.suppliers).to match_array [supplier_managed, supplier_permitted, supplier_unmanaged]
|
||||
expect(oc.coordinator).to eq(distributor_managed)
|
||||
expect(oc.distributors).to match_array [my_distributor, distributor_managed, distributor_permitted, distributor_unmanaged]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -980,9 +980,9 @@ feature '
|
||||
it "shows me an index of order cycles without enterprise columns" do
|
||||
create(:simple_order_cycle, coordinator: enterprise)
|
||||
visit admin_order_cycles_path
|
||||
page.should_not have_selector 'th', text: 'SUPPLIERS'
|
||||
page.should_not have_selector 'th', text: 'COORDINATOR'
|
||||
page.should_not have_selector 'th', text: 'DISTRIBUTORS'
|
||||
expect(page).not_to have_selector 'th', text: 'SUPPLIERS'
|
||||
expect(page).not_to have_selector 'th', text: 'COORDINATOR'
|
||||
expect(page).not_to have_selector 'th', text: 'DISTRIBUTORS'
|
||||
end
|
||||
|
||||
it "creates order cycles", js: true do
|
||||
@@ -998,9 +998,9 @@ feature '
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'pickup instructions'
|
||||
|
||||
# Then my products / variants should already be selected
|
||||
page.should have_checked_field "order_cycle_incoming_exchange_0_variants_#{v1.id}"
|
||||
page.should have_checked_field "order_cycle_incoming_exchange_0_variants_#{v2.id}"
|
||||
page.should have_checked_field "order_cycle_incoming_exchange_0_variants_#{v3.id}"
|
||||
expect(page).to have_checked_field "order_cycle_incoming_exchange_0_variants_#{v1.id}"
|
||||
expect(page).to have_checked_field "order_cycle_incoming_exchange_0_variants_#{v2.id}"
|
||||
expect(page).to have_checked_field "order_cycle_incoming_exchange_0_variants_#{v3.id}"
|
||||
|
||||
# When I unselect a product
|
||||
uncheck "order_cycle_incoming_exchange_0_variants_#{v2.id}"
|
||||
@@ -1009,14 +1009,14 @@ feature '
|
||||
click_button 'Add coordinator fee'
|
||||
click_button 'Add coordinator fee'
|
||||
click_link 'order_cycle_coordinator_fee_1_remove'
|
||||
page.should have_select 'order_cycle_coordinator_fee_0_id'
|
||||
page.should_not have_select 'order_cycle_coordinator_fee_1_id'
|
||||
expect(page).to have_select 'order_cycle_coordinator_fee_0_id'
|
||||
expect(page).not_to have_select 'order_cycle_coordinator_fee_1_id'
|
||||
|
||||
select 'Coord fee', from: 'order_cycle_coordinator_fee_0_id'
|
||||
click_button 'Create'
|
||||
|
||||
# Then my order cycle should have been created
|
||||
page.should have_content 'Your order cycle has been created.'
|
||||
expect(page).to have_content 'Your order cycle has been created.'
|
||||
|
||||
oc = OrderCycle.last
|
||||
|
||||
@@ -1025,16 +1025,16 @@ feature '
|
||||
expect(page).to have_input "oc#{oc.id}[orders_close_at]", value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z")
|
||||
|
||||
# And it should have some variants selected
|
||||
oc.exchanges.incoming.first.variants.count.should == 2
|
||||
oc.exchanges.outgoing.first.variants.count.should == 2
|
||||
expect(oc.exchanges.incoming.first.variants.count).to eq(2)
|
||||
expect(oc.exchanges.outgoing.first.variants.count).to eq(2)
|
||||
|
||||
# And it should have the fee
|
||||
oc.coordinator_fees.should == [fee]
|
||||
expect(oc.coordinator_fees).to eq([fee])
|
||||
|
||||
# And my pickup time and instructions should have been saved
|
||||
ex = oc.exchanges.outgoing.first
|
||||
ex.pickup_time.should == 'pickup time'
|
||||
ex.pickup_instructions.should == 'pickup instructions'
|
||||
expect(ex.pickup_time).to eq('pickup time')
|
||||
expect(ex.pickup_instructions).to eq('pickup instructions')
|
||||
end
|
||||
|
||||
scenario "editing an order cycle" do
|
||||
@@ -1054,19 +1054,19 @@ feature '
|
||||
wait_for_edit_form_to_load_order_cycle(oc)
|
||||
|
||||
# Then I should see the basic settings
|
||||
page.should have_field 'order_cycle_name', with: oc.name
|
||||
page.should have_field 'order_cycle_orders_open_at', with: oc.orders_open_at.to_s
|
||||
page.should have_field 'order_cycle_orders_close_at', with: oc.orders_close_at.to_s
|
||||
page.should have_field 'order_cycle_outgoing_exchange_0_pickup_time', with: 'pickup time'
|
||||
page.should have_field 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'pickup instructions'
|
||||
expect(page).to have_field 'order_cycle_name', with: oc.name
|
||||
expect(page).to have_field 'order_cycle_orders_open_at', with: oc.orders_open_at.to_s
|
||||
expect(page).to have_field 'order_cycle_orders_close_at', with: oc.orders_close_at.to_s
|
||||
expect(page).to have_field 'order_cycle_outgoing_exchange_0_pickup_time', with: 'pickup time'
|
||||
expect(page).to have_field 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'pickup instructions'
|
||||
|
||||
# And I should see the products
|
||||
page.should have_checked_field "order_cycle_incoming_exchange_0_variants_#{v1.id}"
|
||||
page.should have_unchecked_field "order_cycle_incoming_exchange_0_variants_#{v2.id}"
|
||||
page.should have_unchecked_field "order_cycle_incoming_exchange_0_variants_#{v3.id}"
|
||||
expect(page).to have_checked_field "order_cycle_incoming_exchange_0_variants_#{v1.id}"
|
||||
expect(page).to have_unchecked_field "order_cycle_incoming_exchange_0_variants_#{v2.id}"
|
||||
expect(page).to have_unchecked_field "order_cycle_incoming_exchange_0_variants_#{v3.id}"
|
||||
|
||||
# And I should see the coordinator fees
|
||||
page.should have_select 'order_cycle_coordinator_fee_0_id', selected: 'my fee'
|
||||
expect(page).to have_select 'order_cycle_coordinator_fee_0_id', selected: 'my fee'
|
||||
end
|
||||
|
||||
scenario "updating an order cycle" do
|
||||
@@ -1098,19 +1098,19 @@ feature '
|
||||
|
||||
# And I select some fees and update
|
||||
click_link 'order_cycle_coordinator_fee_0_remove'
|
||||
page.should_not have_select 'order_cycle_coordinator_fee_0_id'
|
||||
expect(page).not_to have_select 'order_cycle_coordinator_fee_0_id'
|
||||
click_button 'Add coordinator fee'
|
||||
select 'that fee', from: 'order_cycle_coordinator_fee_0_id'
|
||||
|
||||
# When I update, or update and close, both work
|
||||
click_button 'Update'
|
||||
page.should have_content 'Your order cycle has been updated.'
|
||||
expect(page).to have_content 'Your order cycle has been updated.'
|
||||
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'yyz'
|
||||
click_button 'Update and Close'
|
||||
|
||||
# Then my order cycle should have been updated
|
||||
page.should have_content 'Your order cycle has been updated.'
|
||||
expect(page).to have_content 'Your order cycle has been updated.'
|
||||
oc = OrderCycle.last
|
||||
|
||||
expect(page).to have_input "oc#{oc.id}[name]", value: "Plums & Avos"
|
||||
@@ -1118,16 +1118,16 @@ feature '
|
||||
expect(page).to have_input "oc#{oc.id}[orders_close_at]", value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z")
|
||||
|
||||
# And it should have a variant selected
|
||||
oc.exchanges.incoming.first.variants.should == [v2]
|
||||
oc.exchanges.outgoing.first.variants.should == [v2]
|
||||
expect(oc.exchanges.incoming.first.variants).to eq([v2])
|
||||
expect(oc.exchanges.outgoing.first.variants).to eq([v2])
|
||||
|
||||
# And it should have the fee
|
||||
oc.coordinator_fees.should == [fee2]
|
||||
expect(oc.coordinator_fees).to eq([fee2])
|
||||
|
||||
# And my pickup time and instructions should have been saved
|
||||
ex = oc.exchanges.outgoing.first
|
||||
ex.pickup_time.should == 'xy'
|
||||
ex.pickup_instructions.should == 'yyz'
|
||||
expect(ex.pickup_time).to eq('xy')
|
||||
expect(ex.pickup_instructions).to eq('yyz')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -40,23 +40,23 @@ feature '
|
||||
click_button 'Create'
|
||||
|
||||
expect(current_path).to eq spree.admin_products_path
|
||||
flash_message.should == 'Product "A new product !!!" has been successfully created!'
|
||||
expect(flash_message).to eq('Product "A new product !!!" has been successfully created!')
|
||||
product = Spree::Product.find_by_name('A new product !!!')
|
||||
product.supplier.should == @supplier
|
||||
product.variant_unit.should == 'weight'
|
||||
product.variant_unit_scale.should == 1000
|
||||
product.unit_value.should == 5000
|
||||
product.unit_description.should == ""
|
||||
product.variant_unit_name.should == ""
|
||||
product.primary_taxon_id.should == taxon.id
|
||||
product.price.to_s.should == '19.99'
|
||||
product.on_hand.should == 5
|
||||
product.tax_category_id.should == tax_category.id
|
||||
product.shipping_category.should == shipping_category
|
||||
product.description.should == "<p>A description...</p>"
|
||||
product.group_buy.should be_falsey
|
||||
product.master.option_values.map(&:name).should == ['5kg']
|
||||
product.master.options_text.should == "5kg"
|
||||
expect(product.supplier).to eq(@supplier)
|
||||
expect(product.variant_unit).to eq('weight')
|
||||
expect(product.variant_unit_scale).to eq(1000)
|
||||
expect(product.unit_value).to eq(5000)
|
||||
expect(product.unit_description).to eq("")
|
||||
expect(product.variant_unit_name).to eq("")
|
||||
expect(product.primary_taxon_id).to eq(taxon.id)
|
||||
expect(product.price.to_s).to eq('19.99')
|
||||
expect(product.on_hand).to eq(5)
|
||||
expect(product.tax_category_id).to eq(tax_category.id)
|
||||
expect(product.shipping_category).to eq(shipping_category)
|
||||
expect(product.description).to eq("<p>A description...</p>")
|
||||
expect(product.group_buy).to be_falsey
|
||||
expect(product.master.option_values.map(&:name)).to eq(['5kg'])
|
||||
expect(product.master.options_text).to eq("5kg")
|
||||
end
|
||||
|
||||
scenario "creating an on-demand product", js: true do
|
||||
@@ -81,9 +81,9 @@ feature '
|
||||
|
||||
expect(current_path).to eq spree.admin_products_path
|
||||
product = Spree::Product.find_by_name('Hot Cakes')
|
||||
product.variants.count.should == 1
|
||||
expect(product.variants.count).to eq(1)
|
||||
variant = product.variants.first
|
||||
variant.on_demand.should be true
|
||||
expect(variant.on_demand).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -111,7 +111,7 @@ feature '
|
||||
fill_in 'product_name', with: 'A new product !!!'
|
||||
fill_in 'product_price', with: '19.99'
|
||||
|
||||
page.should have_selector('#product_supplier_id')
|
||||
expect(page).to have_selector('#product_supplier_id')
|
||||
select 'Another Supplier', from: 'product_supplier_id'
|
||||
select 'Weight (g)', from: 'product_variant_unit_with_scale'
|
||||
fill_in 'product_unit_value_with_description', with: '500'
|
||||
@@ -120,15 +120,15 @@ feature '
|
||||
select 'None', from: "product_tax_category_id"
|
||||
|
||||
# Should only have suppliers listed which the user can manage
|
||||
page.should have_select 'product_supplier_id', with_options: [@supplier2.name, @supplier_permitted.name]
|
||||
page.should_not have_select 'product_supplier_id', with_options: [@supplier.name]
|
||||
expect(page).to have_select 'product_supplier_id', with_options: [@supplier2.name, @supplier_permitted.name]
|
||||
expect(page).not_to have_select 'product_supplier_id', with_options: [@supplier.name]
|
||||
|
||||
click_button 'Create'
|
||||
|
||||
flash_message.should == 'Product "A new product !!!" has been successfully created!'
|
||||
expect(flash_message).to eq('Product "A new product !!!" has been successfully created!')
|
||||
product = Spree::Product.find_by_name('A new product !!!')
|
||||
product.supplier.should == @supplier2
|
||||
product.tax_category.should be_nil
|
||||
expect(product.supplier).to eq(@supplier2)
|
||||
expect(product.tax_category).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -141,10 +141,10 @@ feature '
|
||||
select 'Permitted Supplier', from: 'product_supplier_id'
|
||||
select tax_category.name, from: 'product_tax_category_id'
|
||||
click_button 'Update'
|
||||
flash_message.should == 'Product "a product" has been successfully updated!'
|
||||
expect(flash_message).to eq('Product "a product" has been successfully updated!')
|
||||
product.reload
|
||||
product.supplier.should == @supplier_permitted
|
||||
product.tax_category.should == tax_category
|
||||
expect(product.supplier).to eq(@supplier_permitted)
|
||||
expect(product.tax_category).to eq(tax_category)
|
||||
end
|
||||
|
||||
scenario "editing product group buy options" do
|
||||
@@ -157,10 +157,10 @@ feature '
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
flash_message.should == "Product \"#{product.name}\" has been successfully updated!"
|
||||
expect(flash_message).to eq("Product \"#{product.name}\" has been successfully updated!")
|
||||
product.reload
|
||||
product.group_buy.should be true
|
||||
product.group_buy_unit_size.should == 10.0
|
||||
expect(product.group_buy).to be true
|
||||
expect(product.group_buy_unit_size).to eq(10.0)
|
||||
end
|
||||
|
||||
scenario "editing product Search" do
|
||||
@@ -183,8 +183,8 @@ feature '
|
||||
|
||||
# When I navigate to the product properties page
|
||||
visit spree.admin_product_product_properties_path(p)
|
||||
page.should have_select2 'product_product_properties_attributes_0_property_name', selected: 'fooprop'
|
||||
page.should have_field 'product_product_properties_attributes_0_value', with: 'fooval'
|
||||
expect(page).to have_select2 'product_product_properties_attributes_0_property_name', selected: 'fooprop'
|
||||
expect(page).to have_field 'product_product_properties_attributes_0_value', with: 'fooval'
|
||||
|
||||
# And I delete the property
|
||||
accept_alert do
|
||||
@@ -193,8 +193,8 @@ feature '
|
||||
click_button 'Update'
|
||||
|
||||
# Then the property should have been deleted
|
||||
page.should_not have_field 'product_product_properties_attributes_0_property_name', with: 'fooprop'
|
||||
page.should_not have_field 'product_product_properties_attributes_0_value', with: 'fooval'
|
||||
expect(page).not_to have_field 'product_product_properties_attributes_0_property_name', with: 'fooprop'
|
||||
expect(page).not_to have_field 'product_product_properties_attributes_0_value', with: 'fooval'
|
||||
expect(p.reload.property('fooprop')).to be_nil
|
||||
end
|
||||
|
||||
@@ -204,7 +204,7 @@ feature '
|
||||
Spree::Image.create(viewable_id: product.master.id, viewable_type: 'Spree::Variant', alt: "position 1", attachment: image, position: 1)
|
||||
|
||||
visit spree.admin_product_images_path(product)
|
||||
page.should have_selector "table[data-hook='images_table'] td img"
|
||||
expect(page).to have_selector "table[data-hook='images_table'] td img"
|
||||
expect(product.reload.images.count).to eq 1
|
||||
|
||||
accept_alert do
|
||||
|
||||
Reference in New Issue
Block a user