diff --git a/spec/features/admin/inventory_spec.rb b/spec/features/admin/inventory_spec.rb deleted file mode 100644 index d2ea04ad74..0000000000 --- a/spec/features/admin/inventory_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require "spec_helper" - -feature "Managing inventory", js: true do - include AdminHelper - include AuthenticationWorkflow - include WebHelper - - it "shows more than 100 products" do - supplier = create(:supplier_enterprise, sells: "own") - inventory_items = (1..101).map do - product = create(:simple_product, supplier: supplier) - InventoryItem.create!( - enterprise: supplier, - variant: product.variants.first, - visible: true - ) - end - first_variant = inventory_items.first.variant - last_variant = inventory_items.last.variant - first_variant.product.update_attributes!(name: "A First Product") - last_variant.product.update_attributes!(name: "Z Last Product") - quick_login_as supplier.users.first - visit admin_inventory_path - - expect(page).to have_text first_variant.name - expect(page).to have_selector "tr.product", count: 10 - expect(page).to have_button "Show more" - expect(page).to have_button "Show all (91 More)" - - click_button "Show all (91 More)" - expect(page).to have_selector "tr.product", count: 101 - expect(page).to have_text last_variant.name - end -end diff --git a/spec/features/admin/variant_overrides_spec.rb b/spec/features/admin/variant_overrides_spec.rb index a2598be6f1..0533f39629 100644 --- a/spec/features/admin/variant_overrides_spec.rb +++ b/spec/features/admin/variant_overrides_spec.rb @@ -1,32 +1,31 @@ require 'spec_helper' feature " - As an Administrator - With products I can add to my hub's inventory - I want to override the stock level and price of those products + Managing a hub's inventory + I want to override the stock level and price of products Without affecting other hubs that share the same products ", js: true do include AdminHelper include AuthenticationWorkflow include WebHelper - let!(:hub) { create(:distributor_enterprise) } - let!(:hub2) { create(:distributor_enterprise) } - let!(:producer) { create(:supplier_enterprise) } - let!(:producer_managed) { create(:supplier_enterprise) } - let!(:producer_related) { create(:supplier_enterprise) } - let!(:producer_unrelated) { create(:supplier_enterprise) } - let!(:er1) { - create(:enterprise_relationship, parent: producer, child: hub, - permissions_list: [:create_variant_overrides]) - } - let!(:er2) { - create(:enterprise_relationship, parent: producer_related, child: hub, - permissions_list: [:create_variant_overrides]) - } - - context "as an enterprise user" do + context "as the manager of a hub" do + let!(:hub) { create(:distributor_enterprise) } + let!(:hub2) { create(:distributor_enterprise) } + let!(:producer) { create(:supplier_enterprise) } + let!(:producer_managed) { create(:supplier_enterprise) } + let!(:producer_related) { create(:supplier_enterprise) } + let!(:producer_unrelated) { create(:supplier_enterprise) } + let!(:er1) { + create(:enterprise_relationship, parent: producer, child: hub, + permissions_list: [:create_variant_overrides]) + } + let!(:er2) { + create(:enterprise_relationship, parent: producer_related, child: hub, + permissions_list: [:create_variant_overrides]) + } let(:user) { create_enterprise_user enterprises: [hub, producer_managed] } + before { quick_login_as user } describe "selecting a hub" do @@ -455,6 +454,35 @@ feature " end end + context "as the manager of a farm shop" do + it "shows more than 100 products in my inventory" do + supplier = create(:supplier_enterprise, sells: "own") + inventory_items = (1..101).map do + product = create(:simple_product, supplier: supplier) + InventoryItem.create!( + enterprise: supplier, + variant: product.variants.first, + visible: true + ) + end + first_variant = inventory_items.first.variant + last_variant = inventory_items.last.variant + first_variant.product.update_attributes!(name: "A First Product") + last_variant.product.update_attributes!(name: "Z Last Product") + quick_login_as supplier.users.first + visit admin_inventory_path + + expect(page).to have_text first_variant.name + expect(page).to have_selector "tr.product", count: 10 + expect(page).to have_button "Show more" + expect(page).to have_button "Show all (91 More)" + + click_button "Show all (91 More)" + expect(page).to have_selector "tr.product", count: 101 + expect(page).to have_text last_variant.name + end + end + def select_on_demand(variant, value_sym) option_label = I18n.t(value_sym, scope: "js.variant_overrides.on_demand") select option_label, from: "variant-overrides-#{variant.id}-on_demand"