mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Show variants in override variants interface, not just products
This commit is contained in:
@@ -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'
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
%tr.product
|
||||
%td {{ producers[product.producer_id].name }}
|
||||
%td {{ product.name }}
|
||||
%td
|
||||
%td
|
||||
@@ -0,0 +1,5 @@
|
||||
%tr.variant{ng: {repeat: 'variant in product.variants'}}
|
||||
%td
|
||||
%td {{ variant.options_text }}
|
||||
%td {{ variant.price }}
|
||||
%td {{ variant.on_hand }}
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user