diff --git a/app/views/spree/admin/products/override_variants/_products.html.haml b/app/views/spree/admin/products/override_variants/_products.html.haml index 6388656654..3be701d203 100644 --- a/app/views/spree/admin/products/override_variants/_products.html.haml +++ b/app/views/spree/admin/products/override_variants/_products.html.haml @@ -5,9 +5,7 @@ %th Product %th Price %th On hand - %tbody - %tr{ng: {repeat: 'product in products | hubPermissions:hubPermissions:hub.id'}} - %td {{ producers[product.producer_id].name }} - %td {{ product.name }} - %td {{ product.price }} - %td {{ product.on_hand }} + %tbody{ng: {repeat: 'product in products | hubPermissions:hubPermissions:hub.id'}} + = render 'spree/admin/products/override_variants/products_product' + = render 'spree/admin/products/override_variants/products_variants' + diff --git a/app/views/spree/admin/products/override_variants/_products_product.html.haml b/app/views/spree/admin/products/override_variants/_products_product.html.haml new file mode 100644 index 0000000000..ccb3b97f6a --- /dev/null +++ b/app/views/spree/admin/products/override_variants/_products_product.html.haml @@ -0,0 +1,5 @@ +%tr.product + %td {{ producers[product.producer_id].name }} + %td {{ product.name }} + %td + %td diff --git a/app/views/spree/admin/products/override_variants/_products_variants.html.haml b/app/views/spree/admin/products/override_variants/_products_variants.html.haml new file mode 100644 index 0000000000..b15127677a --- /dev/null +++ b/app/views/spree/admin/products/override_variants/_products_variants.html.haml @@ -0,0 +1,5 @@ +%tr.variant{ng: {repeat: 'variant in product.variants'}} + %td + %td {{ variant.options_text }} + %td {{ variant.price }} + %td {{ variant.on_hand }} diff --git a/spec/features/admin/override_variants_spec.rb b/spec/features/admin/override_variants_spec.rb index 1ae981a8aa..1a37e90a84 100644 --- a/spec/features/admin/override_variants_spec.rb +++ b/spec/features/admin/override_variants_spec.rb @@ -12,18 +12,19 @@ feature %q{ use_short_wait let!(:hub) { create(:distributor_enterprise) } + let!(:hub2) { create(:distributor_enterprise) } let!(:producer) { create(:supplier_enterprise) } let!(:er) { create(:enterprise_relationship, parent: producer, child: hub, permissions_list: [:add_to_order_cycle]) } context "as an enterprise user" do - let(:user) { create_enterprise_user enterprises: [hub, producer] } + let(:user) { create_enterprise_user enterprises: [hub, hub2, producer] } before { quick_login_as user } describe "selecting a hub" do it "displays a list of hub choices" do visit '/admin/products/override_variants' - page.should have_select2 'hub_id', options: ['', hub.name] + page.should have_select2 'hub_id', options: ['', hub.name, hub2.name] end it "displays the hub" do @@ -36,23 +37,31 @@ feature %q{ end context "when a hub is selected" do - let!(:product) { create(:simple_product, supplier: producer, price: 1.23, on_hand: 12) } + let!(:product) { create(:simple_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1) } + let!(:variant) { create(:variant, product: product, unit_value: 1, price: 1.23, on_hand: 12) } let!(:producer2) { create(:supplier_enterprise) } - let!(:product2) { create(:simple_product, supplier: producer2, price: 1.23, on_hand: 12) } + let!(:product2) { create(:simple_product, supplier: producer2) } + let!(:er) { create(:enterprise_relationship, parent: producer2, child: hub2, + permissions_list: [:add_to_order_cycle]) } before do + # Remove 'S' option value + variant.option_values.first.destroy + visit '/admin/products/override_variants' select2_select hub.name, from: 'hub_id' click_button 'Go' end - it "displays the list of products" do + it "displays the list of products with variants" do page.should have_table_row ['PRODUCER', 'PRODUCT', 'PRICE', 'ON HAND'] - page.should have_table_row [producer.name, product.name, '1.23', '12'] + page.should have_table_row [producer.name, product.name, '', ''] + page.should have_table_row ['', '1g', '1.23', '12'] end it "filters the products to those the hub can add to an order cycle" do - page.should_not have_table_row [producer2.name, product2.name, '1.23', '12'] + page.should_not have_content producer2.name + page.should_not have_content product2.name end it "products values are affected by overrides"