Merge pull request #3846 from luisramos0/transpec_features

Transpec spec/features
This commit is contained in:
Kristina Lim
2019-05-29 01:17:30 +08:00
committed by GitHub
18 changed files with 426 additions and 426 deletions

View File

@@ -34,9 +34,9 @@ feature '
click_button 'Continue'
# Then I should see the adjustment, with the correct tax
page.should have_selector 'td.label', text: 'Late fee'
page.should have_selector 'td.amount', text: '110'
page.should have_selector 'td.included-tax', text: '10'
expect(page).to have_selector 'td.label', text: 'Late fee'
expect(page).to have_selector 'td.amount', text: '110'
expect(page).to have_selector 'td.included-tax', text: '10'
end
scenario "modifying taxed adjustments on an order" do
@@ -59,8 +59,8 @@ feature '
click_button 'Continue'
# Then the adjustment tax should be cleared
page.should have_selector 'td.amount', text: '110'
page.should have_selector 'td.included-tax', text: '0'
expect(page).to have_selector 'td.amount', text: '110'
expect(page).to have_selector 'td.included-tax', text: '0'
end
scenario "modifying an untaxed adjustment on an order" do
@@ -83,7 +83,7 @@ feature '
click_button 'Continue'
# Then the adjustment tax should be recalculated
page.should have_selector 'td.amount', text: '110'
page.should have_selector 'td.included-tax', text: '10'
expect(page).to have_selector 'td.amount', text: '110'
expect(page).to have_selector 'td.included-tax', text: '10'
end
end

View File

@@ -14,7 +14,7 @@ feature 'Caching' do
it "displays results when things are good" do
# Given matching data
Rails.cache.write "products-json-#{distributor.id}-#{order_cycle.id}", "[1, 2, 3]\n"
OpenFoodNetwork::ProductsRenderer.stub(:new) { double(:pr, products_json: "[1, 2, 3]\n") }
allow(OpenFoodNetwork::ProductsRenderer).to receive(:new) { double(:pr, products_json: "[1, 2, 3]\n") }
# When I visit the cache status page
visit spree.admin_path
@@ -22,13 +22,13 @@ feature 'Caching' do
click_link 'Caching'
# Then I should see some status information
page.should have_content "OK"
expect(page).to have_content "OK"
end
it "displays results when there are errors" do
# Given matching data
Rails.cache.write "products-json-#{distributor.id}-#{order_cycle.id}", "[1, 2, 3]\n"
OpenFoodNetwork::ProductsRenderer.stub(:new) { double(:pr, products_json: "[1, 3]\n") }
allow(OpenFoodNetwork::ProductsRenderer).to receive(:new) { double(:pr, products_json: "[1, 3]\n") }
# When I visit the cache status page
visit spree.admin_path
@@ -36,7 +36,7 @@ feature 'Caching' do
click_link 'Caching'
# Then I should see some status information
page.should have_content "Error"
expect(page).to have_content "Error"
end
end
end

View File

@@ -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"

View File

@@ -17,9 +17,9 @@ feature '
click_link 'Groups'
page.should have_selector 'td', text: group.name
page.should have_selector 'td', text: 'Y'
page.should have_selector 'td', text: e.name
expect(page).to have_selector 'td', text: group.name
expect(page).to have_selector 'td', text: 'Y'
expect(page).to have_selector 'td', text: e.name
end
scenario "creating a new enterprise group", js: true do
@@ -44,13 +44,13 @@ feature '
select2_select 'Victoria', from: 'enterprise_group_address_attributes_state_id'
click_button 'Create'
page.should have_content 'Enterprise group "EGEGEG" has been successfully created!'
expect(page).to have_content 'Enterprise group "EGEGEG" has been successfully created!'
eg = EnterpriseGroup.last
eg.name.should == 'EGEGEG'
eg.description.should == 'This is a description'
eg.on_front_page.should be true
eg.enterprises.should match_array [e1, e2]
expect(eg.name).to eq('EGEGEG')
expect(eg.description).to eq('This is a description')
expect(eg.on_front_page).to be true
expect(eg.enterprises).to match_array [e1, e2]
end
scenario "editing an enterprise group" do
@@ -61,9 +61,9 @@ feature '
click_link 'Groups'
first("a.edit-enterprise-group").click
page.should have_field 'enterprise_group_name', with: 'EGEGEG'
page.should have_checked_field 'enterprise_group_on_front_page'
page.should have_select 'enterprise_group_enterprise_ids', selected: [e1.name, e2.name]
expect(page).to have_field 'enterprise_group_name', with: 'EGEGEG'
expect(page).to have_checked_field 'enterprise_group_on_front_page'
expect(page).to have_select 'enterprise_group_enterprise_ids', selected: [e1.name, e2.name]
fill_in 'enterprise_group_name', with: 'xyzzy'
uncheck 'enterprise_group_on_front_page'
@@ -72,12 +72,12 @@ feature '
select e2.name, from: 'enterprise_group_enterprise_ids'
click_button 'Update'
page.should have_content 'Enterprise group "xyzzy" has been successfully updated!'
expect(page).to have_content 'Enterprise group "xyzzy" has been successfully updated!'
eg = EnterpriseGroup.last
eg.name.should == 'xyzzy'
eg.on_front_page.should be false
eg.enterprises.should == [e2]
expect(eg.name).to eq('xyzzy')
expect(eg.on_front_page).to be false
expect(eg.enterprises).to eq([e2])
end
scenario "re-ordering enterprise groups" do
@@ -86,11 +86,11 @@ feature '
click_link 'Groups'
page.all('td.name').map(&:text).should == ['A', 'B']
expect(page.all('td.name').map(&:text)).to eq(['A', 'B'])
all("a.move-down").first.click
page.all('td.name').map(&:text).should == ['B', 'A']
expect(page.all('td.name').map(&:text)).to eq(['B', 'A'])
all("a.move-up").last.click
page.all('td.name').map(&:text).should == ['A', 'B']
expect(page.all('td.name').map(&:text)).to eq(['A', 'B'])
end
scenario "deleting an enterprise group", js: true do
@@ -101,9 +101,9 @@ feature '
first("a.delete-resource").click
end
page.should have_no_content 'EGEGEG'
expect(page).to have_no_content 'EGEGEG'
EnterpriseGroup.all.should_not include eg
expect(EnterpriseGroup.all).not_to include eg
end
context "as an enterprise user" do

View File

@@ -24,10 +24,10 @@ feature '
# Then I should see the relationships
within('table#enterprise-relationships') do
page.should have_relationship e1, e2, ['to add to order cycle']
page.should have_relationship e2, e3, ['to manage products']
page.should have_relationship e3, e4,
['to add to order cycle', 'to manage products']
expect(page).to have_relationship e1, e2, ['to add to order cycle']
expect(page).to have_relationship e2, e3, ['to manage products']
expect(page).to have_relationship e3, e4,
['to add to order cycle', 'to manage products']
end
end
@@ -47,11 +47,11 @@ feature '
click_button 'Create'
# Wait for row to appear since have_relationship doesn't wait
page.should have_selector 'tr', count: 2
page.should have_relationship e1, e2, ['to add to order cycle', 'to add products to inventory', 'to edit profile']
expect(page).to have_selector 'tr', count: 2
expect(page).to have_relationship e1, e2, ['to add to order cycle', 'to add products to inventory', 'to edit profile']
er = EnterpriseRelationship.where(parent_id: e1, child_id: e2).first
er.should be_present
er.permissions.map(&:name).should match_array ['add_to_order_cycle', 'edit_profile', 'create_variant_overrides']
expect(er).to be_present
expect(er.permissions.map(&:name)).to match_array ['add_to_order_cycle', 'edit_profile', 'create_variant_overrides']
end
scenario "attempting to create a relationship with invalid data" do
@@ -67,7 +67,7 @@ feature '
click_button 'Create'
# Then I should see an error message
page.should have_content "That relationship is already established."
expect(page).to have_content "That relationship is already established."
end.to change(EnterpriseRelationship, :count).by(0)
end
@@ -77,14 +77,14 @@ feature '
er = create(:enterprise_relationship, parent: e1, child: e2, permissions_list: [:add_to_order_cycle])
visit admin_enterprise_relationships_path
page.should have_relationship e1, e2, ['to add to order cycle']
expect(page).to have_relationship e1, e2, ['to add to order cycle']
accept_alert do
first("a.delete-enterprise-relationship").click
end
page.should_not have_relationship e1, e2
EnterpriseRelationship.where(id: er.id).should be_empty
expect(page).not_to have_relationship e1, e2
expect(EnterpriseRelationship.where(id: er.id)).to be_empty
end
end
@@ -103,15 +103,15 @@ feature '
scenario "enterprise user can only see relationships involving their enterprises" do
visit admin_enterprise_relationships_path
page.should have_relationship d1, d2
page.should have_relationship d2, d1
page.should_not have_relationship d2, d3
expect(page).to have_relationship d1, d2
expect(page).to have_relationship d2, d1
expect(page).not_to have_relationship d2, d3
end
scenario "enterprise user can only add their own enterprises as parent" do
visit admin_enterprise_relationships_path
page.should have_select2 'enterprise_relationship_parent_id', options: ['', d1.name]
page.should have_select2 'enterprise_relationship_child_id', with_options: ['', d1.name, d2.name, d3.name]
expect(page).to have_select2 'enterprise_relationship_parent_id', options: ['', d1.name]
expect(page).to have_select2 'enterprise_relationship_child_id', with_options: ['', d1.name, d2.name, d3.name]
end
end

View File

@@ -26,10 +26,10 @@ feature '
# Then I should see the relationships
within('table#enterprise-roles') do
page.should have_relationship u1, e1
page.should have_relationship u1, e2
page.should have_relationship u2, e3
page.should have_relationship u2, e4
expect(page).to have_relationship u1, e1
expect(page).to have_relationship u1, e2
expect(page).to have_relationship u2, e3
expect(page).to have_relationship u2, e4
end
end
@@ -43,9 +43,9 @@ feature '
click_button 'Create'
# Wait for row to appear since have_relationship doesn't wait
page.should have_selector 'tr', count: 3
page.should have_relationship u, e
EnterpriseRole.where(user_id: u, enterprise_id: e).should be_present
expect(page).to have_selector 'tr', count: 3
expect(page).to have_relationship u, e
expect(EnterpriseRole.where(user_id: u, enterprise_id: e)).to be_present
end
scenario "attempting to create a relationship with invalid data" do
@@ -61,7 +61,7 @@ feature '
click_button 'Create'
# Then I should see an error message
page.should have_content "That role is already present."
expect(page).to have_content "That role is already present."
end.to change(EnterpriseRole, :count).by(0)
end
@@ -71,7 +71,7 @@ feature '
er = create(:enterprise_role, user: u, enterprise: e)
visit admin_enterprise_roles_path
page.should have_relationship u, e
expect(page).to have_relationship u, e
within("#enterprise_role_#{er.id}") do
accept_alert do
@@ -80,9 +80,9 @@ feature '
end
# Wait for row to disappear, otherwise have_relationship waits 30 seconds.
page.should_not have_selector "#enterprise_role_#{er.id}"
page.should_not have_relationship u, e
EnterpriseRole.where(id: er.id).should be_empty
expect(page).not_to have_selector "#enterprise_role_#{er.id}"
expect(page).not_to have_relationship u, e
expect(EnterpriseRole.where(id: er.id)).to be_empty
end
describe "using the enterprise managers interface" do

View File

@@ -40,12 +40,12 @@ feature '
scenario "should not be able to see system configuration" do
visit spree.edit_admin_general_settings_path
page.should have_content 'Unauthorized'
expect(page).to have_content 'Unauthorized'
end
scenario "should not be able to see user management" do
visit spree.admin_users_path
page.should have_content 'Unauthorized'
expect(page).to have_content 'Unauthorized'
end
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -24,20 +24,20 @@ feature '
visit spree.edit_admin_image_settings_path
# All the styles should default to "Unchanged"
page.should have_select 'attachment_styles_format_mini', selected: 'Unchanged'
page.should have_select 'attachment_styles_format_small', selected: 'Unchanged'
page.should have_select 'attachment_styles_format_product', selected: 'Unchanged'
page.should have_select 'attachment_styles_format_large', selected: 'Unchanged'
expect(page).to have_select 'attachment_styles_format_mini', selected: 'Unchanged'
expect(page).to have_select 'attachment_styles_format_small', selected: 'Unchanged'
expect(page).to have_select 'attachment_styles_format_product', selected: 'Unchanged'
expect(page).to have_select 'attachment_styles_format_large', selected: 'Unchanged'
# When I change a style to "PNG" and save
select 'PNG', from: 'attachment_styles_format_mini'
click_button 'Update'
# Then the change should be saved to the image formats
page.should have_content "Image Settings successfully updated."
page.should have_select 'attachment_styles_format_mini', selected: 'PNG'
expect(page).to have_content "Image Settings successfully updated."
expect(page).to have_select 'attachment_styles_format_mini', selected: 'PNG'
styles = Spree::Image.attachment_definitions[:attachment][:styles]
styles[:mini].should == ['48x48>', :png]
expect(styles[:mini]).to eq(['48x48>', :png])
end
end

View File

@@ -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

View File

@@ -11,7 +11,7 @@ feature '
context "as an enterprise user" do
before do
@enterprise_user = create_enterprise_user
Spree::Admin::OverviewController.any_instance.stub(:spree_current_user).and_return @enterprise_user
allow_any_instance_of(Spree::Admin::OverviewController).to receive(:spree_current_user).and_return @enterprise_user
quick_login_as @enterprise_user
end
@@ -24,8 +24,8 @@ feature '
it "displays a link to the map page" do
visit '/admin'
page.should have_selector ".dashboard_item h3", text: "Your profile live"
page.should have_selector ".dashboard_item .button.bottom", text: "SEE #{d1.name.upcase} LIVE"
expect(page).to have_selector ".dashboard_item h3", text: "Your profile live"
expect(page).to have_selector ".dashboard_item .button.bottom", text: "SEE #{d1.name.upcase} LIVE"
end
context "when visibilty is set to false" do
@@ -36,7 +36,7 @@ feature '
it "displays a message telling how to set visibility" do
visit '/admin'
page.should have_selector ".alert-box", text: "To allow people to find you, turn on your visibility under Manage #{d1.name}."
expect(page).to have_selector ".alert-box", text: "To allow people to find you, turn on your visibility under Manage #{d1.name}."
end
end
@@ -79,12 +79,12 @@ feature '
context "but no products or order cycles" do
it "prompts the user to create a new product and to manage order cycles" do
visit '/admin'
page.should have_selector ".dashboard_item#products h3", text: "Products"
page.should have_selector ".dashboard_item#products .list-item", text: "You don't have any active products."
page.should have_selector ".dashboard_item#products .button.bottom", text: "CREATE A NEW PRODUCT"
page.should have_selector ".dashboard_item#order_cycles h3", text: "Order Cycles"
page.should have_selector ".dashboard_item#order_cycles .list-item", text: "You don't have any active order cycles."
page.should have_selector ".dashboard_item#order_cycles .button.bottom", text: "MANAGE ORDER CYCLES"
expect(page).to have_selector ".dashboard_item#products h3", text: "Products"
expect(page).to have_selector ".dashboard_item#products .list-item", text: "You don't have any active products."
expect(page).to have_selector ".dashboard_item#products .button.bottom", text: "CREATE A NEW PRODUCT"
expect(page).to have_selector ".dashboard_item#order_cycles h3", text: "Order Cycles"
expect(page).to have_selector ".dashboard_item#order_cycles .list-item", text: "You don't have any active order cycles."
expect(page).to have_selector ".dashboard_item#order_cycles .button.bottom", text: "MANAGE ORDER CYCLES"
end
end
@@ -94,12 +94,12 @@ feature '
it "displays information about products and order cycles" do
visit '/admin'
page.should have_selector ".dashboard_item#products h3", text: "Products"
page.should have_selector ".dashboard_item#products .list-item", text: "You don't have any active products."
page.should have_selector ".dashboard_item#products .button.bottom", text: "CREATE A NEW PRODUCT"
page.should have_selector ".dashboard_item#order_cycles h3", text: "Order Cycles"
page.should have_selector ".dashboard_item#order_cycles .list-item", text: "You don't have any active order cycles."
page.should have_selector ".dashboard_item#order_cycles .button.bottom", text: "MANAGE ORDER CYCLES"
expect(page).to have_selector ".dashboard_item#products h3", text: "Products"
expect(page).to have_selector ".dashboard_item#products .list-item", text: "You don't have any active products."
expect(page).to have_selector ".dashboard_item#products .button.bottom", text: "CREATE A NEW PRODUCT"
expect(page).to have_selector ".dashboard_item#order_cycles h3", text: "Order Cycles"
expect(page).to have_selector ".dashboard_item#order_cycles .list-item", text: "You don't have any active order cycles."
expect(page).to have_selector ".dashboard_item#order_cycles .button.bottom", text: "MANAGE ORDER CYCLES"
end
end
end

View File

@@ -24,10 +24,10 @@ feature '
check "payment_method_distributor_ids_#{@distributors[0].id}"
click_button 'Create'
flash_message.should == 'Payment Method has been successfully created!'
expect(flash_message).to eq('Payment Method has been successfully created!')
payment_method = Spree::PaymentMethod.find_by_name('Cheque payment method')
payment_method.distributors.should == [@distributors[0]]
expect(payment_method.distributors).to eq([@distributors[0]])
end
context "using stripe connect" do
@@ -148,12 +148,12 @@ feature '
find(:css, "tags-input .tags input").set "local\n"
click_button 'Create'
flash_message.should == 'Payment Method has been successfully created!'
expect(flash_message).to eq('Payment Method has been successfully created!')
expect(first('tags-input .tag-list ti-tag-item')).to have_content "local"
payment_method = Spree::PaymentMethod.find_by_name('Cheque payment method')
payment_method.distributors.should == [distributor1]
payment_method.tag_list.should == ["local"]
expect(payment_method.distributors).to eq([distributor1])
expect(payment_method.tag_list).to eq(["local"])
end
it "shows me only payment methods I have access to" do
@@ -163,9 +163,9 @@ feature '
visit spree.admin_payment_methods_path
page.should have_content pm1.name
page.should have_content pm2.name
page.should_not have_content pm3.name
expect(page).to have_content pm1.name
expect(page).to have_content pm2.name
expect(page).not_to have_content pm3.name
end
it "does not show duplicates of payment methods" do
@@ -173,7 +173,7 @@ feature '
pm2
visit spree.admin_payment_methods_path
page.should have_selector 'td', text: 'Two', count: 1
expect(page).to have_selector 'td', text: 'Two', count: 1
end
pending "shows me only payment methods for the enterprise I select" do
@@ -186,8 +186,8 @@ feature '
click_link "Payment Methods"
end
page.should have_content pm1.name
page.should have_content pm2.name
expect(page).to have_content pm1.name
expect(page).to have_content pm2.name
click_link 'Enterprises'
within("#e_#{distributor2.id}") { click_link 'Settings' }
@@ -195,8 +195,8 @@ feature '
click_link "Payment Methods"
end
page.should_not have_content pm1.name
page.should have_content pm2.name
expect(page).not_to have_content pm1.name
expect(page).to have_content pm2.name
end
end
end

View File

@@ -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

View File

@@ -40,7 +40,7 @@ feature "
click_link 'Products'
click_link 'Inventory'
page.should have_select2 'hub_id', options: [hub.name] # Selects the hub automatically when only one is available
expect(page).to have_select2 'hub_id', options: [hub.name] # Selects the hub automatically when only one is available
end
end
@@ -72,20 +72,20 @@ feature "
context "with no overrides" do
it "displays the list of products with variants" do
page.should have_table_row ['PRODUCER', 'PRODUCT', 'PRICE', 'ON HAND', 'ON DEMAND?']
page.should have_table_row [producer.name, product.name, '', '', '']
page.should have_input "variant-overrides-#{variant.id}-price", placeholder: '1.23'
page.should have_input "variant-overrides-#{variant.id}-count_on_hand", placeholder: '12'
expect(page).to have_table_row ['PRODUCER', 'PRODUCT', 'PRICE', 'ON HAND', 'ON DEMAND?']
expect(page).to have_table_row [producer.name, product.name, '', '', '']
expect(page).to have_input "variant-overrides-#{variant.id}-price", placeholder: '1.23'
expect(page).to have_input "variant-overrides-#{variant.id}-count_on_hand", placeholder: '12'
page.should have_table_row [producer_related.name, product_related.name, '', '', '']
page.should have_input "variant-overrides-#{variant_related.id}-price", placeholder: '2.34'
page.should have_input "variant-overrides-#{variant_related.id}-count_on_hand", placeholder: '23'
expect(page).to have_table_row [producer_related.name, product_related.name, '', '', '']
expect(page).to have_input "variant-overrides-#{variant_related.id}-price", placeholder: '2.34'
expect(page).to have_input "variant-overrides-#{variant_related.id}-count_on_hand", placeholder: '23'
# filters the products to those the hub can override
page.should_not have_content producer_managed.name
page.should_not have_content product_managed.name
page.should_not have_content producer_unrelated.name
page.should_not have_content product_unrelated.name
expect(page).not_to have_content producer_managed.name
expect(page).not_to have_content product_managed.name
expect(page).not_to have_content producer_unrelated.name
expect(page).not_to have_content product_unrelated.name
# Filters based on the producer select filter
expect(page).to have_selector "#v_#{variant.id}"
@@ -141,20 +141,20 @@ feature "
fill_in "variant-overrides-#{variant.id}-price", with: '777.77'
select_on_demand variant, :no
fill_in "variant-overrides-#{variant.id}-count_on_hand", with: '123'
page.should have_content "Changes to one override remain unsaved."
expect(page).to have_content "Changes to one override remain unsaved."
expect do
click_button 'Save Changes'
page.should have_content "Changes saved."
expect(page).to have_content "Changes saved."
end.to change(VariantOverride, :count).by(1)
vo = VariantOverride.last
vo.variant_id.should == variant.id
vo.hub_id.should == hub.id
vo.sku.should == "NEWSKU"
vo.price.should == 777.77
expect(vo.variant_id).to eq(variant.id)
expect(vo.hub_id).to eq(hub.id)
expect(vo.sku).to eq("NEWSKU")
expect(vo.price).to eq(777.77)
expect(vo.on_demand).to eq(false)
vo.count_on_hand.should == 123
expect(vo.count_on_hand).to eq(123)
end
describe "creating and then updating the new override" do
@@ -163,57 +163,57 @@ feature "
fill_in "variant-overrides-#{variant.id}-price", with: '777.77'
select_on_demand variant, :no
fill_in "variant-overrides-#{variant.id}-count_on_hand", with: '123'
page.should have_content "Changes to one override remain unsaved."
expect(page).to have_content "Changes to one override remain unsaved."
expect do
click_button 'Save Changes'
page.should have_content "Changes saved."
expect(page).to have_content "Changes saved."
end.to change(VariantOverride, :count).by(1)
# And I update its settings without reloading the page
fill_in "variant-overrides-#{variant.id}-price", with: '111.11'
fill_in "variant-overrides-#{variant.id}-count_on_hand", with: '111'
page.should have_content "Changes to one override remain unsaved."
expect(page).to have_content "Changes to one override remain unsaved."
# Then I shouldn't see a new override
expect do
click_button 'Save Changes'
page.should have_content "Changes saved."
expect(page).to have_content "Changes saved."
end.to change(VariantOverride, :count).by(0)
# And the override should be updated
vo = VariantOverride.last
vo.variant_id.should == variant.id
vo.hub_id.should == hub.id
vo.price.should == 111.11
expect(vo.variant_id).to eq(variant.id)
expect(vo.hub_id).to eq(hub.id)
expect(vo.price).to eq(111.11)
expect(vo.on_demand).to eq(false)
vo.count_on_hand.should == 111
expect(vo.count_on_hand).to eq(111)
end
end
it "displays an error when unauthorised to access the page" do
fill_in "variant-overrides-#{variant.id}-price", with: '777.77'
fill_in "variant-overrides-#{variant.id}-count_on_hand", with: '123'
page.should have_content "Changes to one override remain unsaved."
expect(page).to have_content "Changes to one override remain unsaved."
user.enterprises.clear
expect do
click_button 'Save Changes'
page.should have_content "I couldn't get authorisation to save those changes, so they remain unsaved."
expect(page).to have_content "I couldn't get authorisation to save those changes, so they remain unsaved."
end.to change(VariantOverride, :count).by(0)
end
it "displays an error when unauthorised to update a particular override" do
fill_in "variant-overrides-#{variant_related.id}-price", with: '777.77'
fill_in "variant-overrides-#{variant_related.id}-count_on_hand", with: '123'
page.should have_content "Changes to one override remain unsaved."
expect(page).to have_content "Changes to one override remain unsaved."
er2.destroy
expect do
click_button 'Save Changes'
page.should have_content "I couldn't get authorisation to save those changes, so they remain unsaved."
expect(page).to have_content "I couldn't get authorisation to save those changes, so they remain unsaved."
end.to change(VariantOverride, :count).by(0)
end
end
@@ -235,7 +235,7 @@ feature "
end
it "product values are affected by overrides" do
page.should have_input "variant-overrides-#{variant.id}-price", with: '77.77', placeholder: '1.23'
expect(page).to have_input "variant-overrides-#{variant.id}-price", with: '77.77', placeholder: '1.23'
expect(page).to have_input "variant-overrides-#{variant.id}-count_on_hand", with: "", placeholder: I18n.t("js.variants.on_demand.yes")
expect(page).to have_select "variant-overrides-#{variant.id}-on_demand", selected: I18n.t("js.variant_overrides.on_demand.yes")
@@ -246,19 +246,19 @@ feature "
fill_in "variant-overrides-#{variant.id}-price", with: '22.22'
select_on_demand variant, :no
fill_in "variant-overrides-#{variant.id}-count_on_hand", with: '8888'
page.should have_content "Changes to one override remain unsaved."
expect(page).to have_content "Changes to one override remain unsaved."
expect do
click_button 'Save Changes'
page.should have_content "Changes saved."
expect(page).to have_content "Changes saved."
end.to change(VariantOverride, :count).by(0)
vo.reload
vo.variant_id.should == variant.id
vo.hub_id.should == hub.id
vo.price.should == 22.22
expect(vo.variant_id).to eq(variant.id)
expect(vo.hub_id).to eq(hub.id)
expect(vo.price).to eq(22.22)
expect(vo.on_demand).to eq(false)
vo.count_on_hand.should == 8888
expect(vo.count_on_hand).to eq(8888)
end
it "updates on_demand settings" do
@@ -310,24 +310,24 @@ feature "
end
end
page.uncheck "variant-overrides-#{variant.id}-resettable"
page.should have_content "Changes to 2 overrides remain unsaved."
expect(page).to have_content "Changes to 2 overrides remain unsaved."
expect do
click_button 'Save Changes'
page.should have_content "Changes saved."
expect(page).to have_content "Changes saved."
end.to change(VariantOverride, :count).by(-2)
VariantOverride.where(id: vo.id).should be_empty
VariantOverride.where(id: vo3.id).should be_empty
expect(VariantOverride.where(id: vo.id)).to be_empty
expect(VariantOverride.where(id: vo3.id)).to be_empty
end
it "resets stock to defaults" do
first("div#bulk-actions-dropdown").click
first("div#bulk-actions-dropdown div.menu div.menu_item", text: "Reset Stock Levels To Defaults").click
page.should have_content 'Stocks reset to defaults.'
expect(page).to have_content 'Stocks reset to defaults.'
vo.reload
expect(page).to have_input "variant-overrides-#{variant.id}-count_on_hand", with: "1000", placeholder: ""
vo.count_on_hand.should == 1000
expect(vo.count_on_hand).to eq(1000)
end
it "doesn't reset stock levels if the behaviour is disabled" do
@@ -335,14 +335,14 @@ feature "
first("div#bulk-actions-dropdown div.menu div.menu_item", text: "Reset Stock Levels To Defaults").click
vo_no_reset.reload
expect(page).to have_input "variant-overrides-#{variant2.id}-count_on_hand", with: "40", placeholder: ""
vo_no_reset.count_on_hand.should == 40
expect(vo_no_reset.count_on_hand).to eq(40)
end
it "prompts to save changes before reset if any are pending" do
fill_in "variant-overrides-#{variant.id}-price", with: '200'
first("div#bulk-actions-dropdown").click
first("div#bulk-actions-dropdown div.menu div.menu_item", text: "Reset Stock Levels To Defaults").click
page.should have_content "Save changes first"
expect(page).to have_content "Save changes first"
end
describe "ensuring that on demand and count on hand settings are compatible" do

View File

@@ -21,7 +21,7 @@ feature '
click_button 'Create'
# Then the variant should have been created
page.should have_content "Variant \"#{p.name}\" has been successfully created!"
expect(page).to have_content "Variant \"#{p.name}\" has been successfully created!"
end
scenario "editing unit value and description for a variant", js: true do
@@ -42,19 +42,19 @@ feature '
expect(page).to have_no_selector "div[data-hook='presentation'] input"
# And I should see unit value and description fields for the unit-related option value
page.should have_field "unit_value_human", with: "1"
page.should have_field "variant_unit_description", with: "foo"
expect(page).to have_field "unit_value_human", with: "1"
expect(page).to have_field "variant_unit_description", with: "foo"
# When I update the fields and save the variant
fill_in "unit_value_human", with: "123"
fill_in "variant_unit_description", with: "bar"
click_button 'Update'
page.should have_content %(Variant "#{p.name}" has been successfully updated!)
expect(page).to have_content %(Variant "#{p.name}" has been successfully updated!)
# Then the unit value and description should have been saved
v.reload
v.unit_value.should == 123
v.unit_description.should == 'bar'
expect(v.unit_value).to eq(123)
expect(v.unit_description).to eq('bar')
end
describe "editing on hand and on demand values", js: true do
@@ -68,12 +68,12 @@ feature '
it "allows changing the on_hand value" do
visit spree.edit_admin_product_variant_path(product, variant)
page.should have_field "variant_on_hand", with: variant.on_hand
page.should have_unchecked_field "variant_on_demand"
expect(page).to have_field "variant_on_hand", with: variant.on_hand
expect(page).to have_unchecked_field "variant_on_demand"
fill_in "variant_on_hand", with: "123"
click_button 'Update'
page.should have_content %(Variant "#{product.name}" has been successfully updated!)
expect(page).to have_content %(Variant "#{product.name}" has been successfully updated!)
end
it "allows changing the on_demand value" do
@@ -81,10 +81,10 @@ feature '
check "variant_on_demand"
# on_hand reflects the change in on_demand
page.should have_field "variant_on_hand", with: "Infinity", disabled: true
expect(page).to have_field "variant_on_hand", with: "Infinity", disabled: true
click_button 'Update'
page.should have_content %(Variant "#{product.name}" has been successfully updated!)
expect(page).to have_content %(Variant "#{product.name}" has been successfully updated!)
end
it "memorizes on_hand value previously entered if enabling and disabling on_demand" do
@@ -94,7 +94,7 @@ feature '
uncheck "variant_on_demand"
# on_hand shows the memorized value, not the original DB value
page.should have_field "variant_on_hand", with: "123"
expect(page).to have_field "variant_on_hand", with: "123"
end
end
@@ -111,10 +111,10 @@ feature '
end
end
page.should_not have_selector "tr#spree_variant_#{v.id}"
expect(page).not_to have_selector "tr#spree_variant_#{v.id}"
v.reload
v.deleted_at.should_not be_nil
expect(v.deleted_at).not_to be_nil
end
scenario "editing display name for a variant", js: true do
@@ -127,18 +127,18 @@ feature '
page.find('table.index .icon-edit').click
# It should allow the display name to be changed
page.should have_field "variant_display_name"
page.should have_field "variant_display_as"
expect(page).to have_field "variant_display_name"
expect(page).to have_field "variant_display_as"
# When I update the fields and save the variant
fill_in "variant_display_name", with: "Display Name"
fill_in "variant_display_as", with: "Display As This"
click_button 'Update'
page.should have_content %(Variant "#{p.name}" has been successfully updated!)
expect(page).to have_content %(Variant "#{p.name}" has been successfully updated!)
# Then the displayed values should have been saved
v.reload
v.display_name.should == "Display Name"
v.display_as.should == "Display As This"
expect(v.display_name).to eq("Display Name")
expect(v.display_as).to eq("Display As This")
end
end

View File

@@ -14,26 +14,26 @@ feature 'External services' do
end
it "is not included in dev" do
Rails.env.stub(:development?) { true }
allow(Rails.env).to receive(:development?) { true }
visit root_path
expect(script_content(with: 'bugherd')).to be_nil
end
it "is included in staging" do
Rails.env.stub(:staging?) { true }
allow(Rails.env).to receive(:staging?) { true }
visit root_path
expect(script_content(with: 'bugherd')).not_to be_nil
end
it "is included in production" do
Rails.env.stub(:production?) { true }
allow(Rails.env).to receive(:production?) { true }
visit root_path
expect(script_content(with: 'bugherd')).not_to be_nil
end
end
context "in an environment where BugHerd is displayed" do
before { Rails.env.stub(:staging?) { true } }
before { allow(Rails.env).to receive(:staging?) { true } }
context "when there is no API key set" do
before { Spree::Config.bugherd_api_key = nil }