Add on_demand field

But 'Array parameters do not play well with the check_box helper.'

...
This commit is contained in:
David Cook
2023-11-10 17:01:31 +11:00
parent 7aefa834bf
commit 55cd8a6773
3 changed files with 9 additions and 2 deletions

View File

@@ -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

View File

@@ -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") }

View File

@@ -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