Add unit name (items) field

This commit is contained in:
David Cook
2024-02-29 15:05:13 +11:00
parent bfd6319cf2
commit b3cf977c96
2 changed files with 21 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
class: "fullwidth no-input",
'aria-label': t('admin.products_page.columns.unit_scale'),
data: { "controller": "tom-select", "tom-select-options-value": '{ "plugins": [] }' }
= f.text_field :variant_unit_name, 'aria-label': t('items')
%td.align-right
-# empty
%td.align-right

View File

@@ -236,7 +236,6 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do
click_button "Save changes"
expect(page).to have_content "Changes saved"
product_a.reload
variant_a1.reload
}.to change{ variant_a1.on_demand }.to(true)
@@ -245,6 +244,26 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do
end
end
it "saves a custom item unit name" do
within row_containing_name("Apples") do
tomselect_select "Items", from: "Unit scale"
fill_in "Items", with: "box"
end
expect {
click_button "Save changes"
expect(page).to have_content "Changes saved"
product_a.reload
}.to change{ product_a.variant_unit }.to("items")
.and change{ product_a.variant_unit_name }.to("box")
within row_containing_name("Apples") do
pending
expect(page).to have_content "Items (box)"
end
end
it "discards changes and reloads latest data" do
within row_containing_name("Apples") do
fill_in "Name", with: "Pommes"