Remove unwanted space at the end of the price

This `number_to_currency` method seems to display an extra space, not necessary when unit is `''`
Strip it.

Update specs as well. Thanks @filipefurtad0 for specs!!!
This commit is contained in:
Jean-Baptiste Bellet
2023-06-22 15:12:28 +02:00
parent 6b84fbf2b8
commit 2fcf706aa3
2 changed files with 6 additions and 10 deletions

View File

@@ -23,7 +23,7 @@
= f.text_field :sku, class: 'fullwidth'
.field
= f.label :price, t('.price')
= f.text_field :price, class: 'fullwidth', "ng-model" => "variant.price", "ng-init" => "variant.price = '#{number_to_currency(@variant.price, unit: '')}'"
= f.text_field :price, class: 'fullwidth', "ng-model" => "variant.price", "ng-init" => "variant.price = '#{number_to_currency(@variant.price, unit: '').strip}'"
.field
= hidden_field_tag 'product_variant_unit', @product.variant_unit
= hidden_field_tag 'product_variant_unit_name', @product.variant_unit_name
@@ -64,4 +64,4 @@
- value = number_with_precision(@variant.send(field), precision: 2)
= f.number_field field, value: value, class: 'fullwidth', step: 0.01
.clear
.clear

View File

@@ -208,10 +208,10 @@ describe '
page.find('table.index .icon-edit').click
# assert on the price field
expect(page).to have_field "variant_price", with: "19,99 "
expect(page).to have_field "variant_price", with: "19,99"
# When I update the fields and save the variant
fill_in "variant_price", with: "12,50 "
fill_in "variant_price", with: "12,50"
click_button 'Actualizar'
expect(page).to have_content \
%(Variant "#{product.name}" ha sido actualizado exitosamente)
@@ -231,13 +231,9 @@ describe '
end
it_behaves_like "with localization", false, ".", ","
it_behaves_like "with localization", true, ".", "," do
before { pending("#11085") }
end
it_behaves_like "with localization", true, ".", ","
it_behaves_like "with localization", false, ",", "."
it_behaves_like "with localization", true, ",", "." do
before { pending("#11085") }
end
it_behaves_like "with localization", true, ",", "."
end
end