mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Run transpec in a few spec/features/admin specs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user