12332 - Fix rubocop Rails/I18nLocaleAssignment errors

- use I18n.with_locale method rather than direct locale assignment
This commit is contained in:
Ahmed Ejaz
2024-04-07 00:17:21 +05:00
committed by Maikel Linke
parent 89033579bd
commit 693b9bd171
5 changed files with 28 additions and 36 deletions

View File

@@ -60,14 +60,12 @@ describe Spree::Variant do
context "price parsing" do
before(:each) do
I18n.locale = I18n.default_locale
I18n.backend.store_translations(:de,
{ number: { currency: { format: { delimiter: '.',
separator: ',' } } } })
end
after do
I18n.locale = I18n.default_locale
default_locale = I18n.default_locale
I18n.with_locale(default_locale) do
I18n.backend.store_translations(:de,
{ number: { currency: { format: { delimiter: '.',
separator: ',' } } } })
end
end
context "price=" do
@@ -80,17 +78,19 @@ describe Spree::Variant do
context "with decimal comma" do
it "captures the proper amount for a formatted price" do
I18n.locale = :es
variant.price = '1.599,99'
expect(variant.price).to eq 1599.99
I18n.with_locale(:es) do
variant.price = '1.599,99'
expect(variant.price).to eq 1599.99
end
end
end
context "with a numeric price" do
it "uses the price as is" do
I18n.locale = :es
variant.price = 1599.99
expect(variant.price).to eq 1599.99
I18n.with_locale(:es) do
variant.price = 1599.99
expect(variant.price).to eq 1599.99
end
end
end
end