Add on_hand input

This commit is contained in:
David Cook
2023-11-10 16:21:13 +11:00
parent 4d22123e02
commit 7aefa834bf
3 changed files with 13 additions and 12 deletions

View File

@@ -85,8 +85,10 @@
%td.field
= variant_form.text_field :price, 'aria-label': t('admin.products_page.columns.price'), value: number_to_currency(variant.price, unit: '')&.strip # TODO: add a spec to prove that this formatting is necessary. If so, it should be in a shared form helper for currency inputs
= error_message_on variant, :price
%td.align-right
.content= variant.on_hand || 0 #TODO: spec for this according to requirements.
%td.field
%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
%td.align-left
.content= variant.product.supplier&.name # same as product
%td.align-left

View File

@@ -30,11 +30,8 @@ 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)
create(:variant, product: product_a, display_name: "Medium box", sku: "APL-01", price: 5.25,
on_hand: 5)
}
let!(:product_c) { create(:simple_product, name: "Carrots", sku: "CAR-00") }
let!(:product_b) { create(:simple_product, name: "Bananas", sku: "BAN-00") }
@@ -73,6 +70,7 @@ describe ProductsReflex, type: :reflex, feature: :admin_style_v3 do
"display_name" => "Large box",
"sku" => "POM-01",
"price" => "10.25",
"on_hand" => "6",
}
],
}
@@ -87,6 +85,7 @@ describe ProductsReflex, type: :reflex, feature: :admin_style_v3 do
.and change{ variant_a1.display_name }.to("Large box")
.and change{ variant_a1.sku }.to("POM-01")
.and change{ variant_a1.price }.to(10.25)
.and change{ variant_a1.on_hand }.to(6)
end
describe "sorting" do

View File

@@ -194,11 +194,8 @@ 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)
create(:variant, product: product_a, display_name: "Medium box", sku: "APL-01", price: 5.25,
on_hand: 5)
}
let!(:product_a) { create(:simple_product, name: "Apples", sku: "APL-00") }
before do
@@ -214,6 +211,7 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3
fill_in "Name", with: "Large box"
fill_in "SKU", with: "POM-01"
fill_in "Price", with: "10.25"
fill_in "On Hand", with: "6"
end
expect {
@@ -225,6 +223,7 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3
.and change{ variant_a1.display_name }.to("Large box")
.and change{ variant_a1.sku }.to("POM-01")
.and change{ variant_a1.price }.to(10.25)
.and change{ variant_a1.on_hand }.to(6)
within row_containing_name("Pommes") do
expect(page).to have_field "Name", with: "Pommes"
@@ -234,6 +233,7 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3
expect(page).to have_field "Name", with: "Large box"
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"
end
pending