From 55cd8a6773247ea3e75bb096d4c8618858387dd0 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 10 Nov 2023 17:01:31 +1100 Subject: [PATCH] Add on_demand field But 'Array parameters do not play well with the check_box helper.' ... --- app/views/admin/products_v3/_table.html.haml | 3 +++ spec/reflexes/products_reflex_spec.rb | 2 +- spec/system/admin/products_v3/products_spec.rb | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/admin/products_v3/_table.html.haml b/app/views/admin/products_v3/_table.html.haml index da8de1bf3b..77cc0656e0 100644 --- a/app/views/admin/products_v3/_table.html.haml +++ b/app/views/admin/products_v3/_table.html.haml @@ -89,6 +89,9 @@ %div.on-hand__wrapper = variant_form.number_field :on_hand, 'aria-label': t('admin.products_page.columns.on_hand') = error_message_on variant, :on_hand + = variant_form.label :on_demand do + = variant_form.check_box :on_demand + = t('admin.products_page.columns.on_demand') %td.align-left .content= variant.product.supplier&.name # same as product %td.align-left diff --git a/spec/reflexes/products_reflex_spec.rb b/spec/reflexes/products_reflex_spec.rb index 792d9667bd..e45ff99e9a 100644 --- a/spec/reflexes/products_reflex_spec.rb +++ b/spec/reflexes/products_reflex_spec.rb @@ -31,7 +31,7 @@ describe ProductsReflex, type: :reflex, feature: :admin_style_v3 do describe '#bulk_update' do let!(:variant_a1) { create(:variant, product: product_a, display_name: "Medium box", sku: "APL-01", price: 5.25, - on_hand: 5) + on_hand: 5, on_demand: false) } let!(:product_c) { create(:simple_product, name: "Carrots", sku: "CAR-00") } let!(:product_b) { create(:simple_product, name: "Bananas", sku: "BAN-00") } diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index e1560d3ee3..4c8d1885af 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -195,7 +195,7 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3 describe "updating" do let!(:variant_a1) { create(:variant, product: product_a, display_name: "Medium box", sku: "APL-01", price: 5.25, - on_hand: 5) + on_hand: 5, on_demand: false) } let!(:product_a) { create(:simple_product, name: "Apples", sku: "APL-00") } before do @@ -212,6 +212,7 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3 fill_in "SKU", with: "POM-01" fill_in "Price", with: "10.25" fill_in "On Hand", with: "6" + check "On Demand" end expect { @@ -224,6 +225,8 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3 .and change{ variant_a1.sku }.to("POM-01") .and change{ variant_a1.price }.to(10.25) .and change{ variant_a1.on_hand }.to(6) + pending "Array parameters do not play well with the check_box helper." + # .and change{ variant_a1.on_demand }.to(true) within row_containing_name("Pommes") do expect(page).to have_field "Name", with: "Pommes" @@ -234,6 +237,7 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3 expect(page).to have_field "SKU", with: "POM-01" expect(page).to have_field "Price", with: "10.25" expect(page).to have_field "On Hand", with: "6" + expect(page).to have_field "On Demand", checked: true end pending