Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Stub i18n.locale to fix flaky webhooks tests (#11830)
nciemniak8f4ceda4e24a
diff --git a/core/spec/helpers/base_helper_spec.rb b/core/spec/helpers/base_helper_spec.rbindex 93e71ef925..31aef6bba9 100644--- a/core/spec/helpers/base_helper_spec.rb+++ b/core/spec/helpers/base_helper_spec.rb@@ -151,7 +151,7 @@ describe Spree::BaseHelper, type: :helper docontext 'when try_spree_current_user defined' dobefore do- I18n.locale = I18n.default_locale+ allow(I18n).to receive(:locale).and_return(I18n.default_locale)allow_any_instance_of(described_class).to receive(:try_spree_current_user).and_return(user)end@@ -183,7 +183,9 @@ describe Spree::BaseHelper, type: :helper docontext 'when try_spree_current_user is undefined' dolet(:current_currency) { 'USD' }- before { I18n.locale = I18n.default_locale }+ before do+ allow(I18n).to receive(:locale).and_return(I18n.default_locale)+ endit 'returns base cache key' doexpect(base_cache_key).to eq [:en, 'USD', nil, nil]diff --git a/core/spec/lib/spree/core/controller_helpers/locale_spec.rb b/core/spec/lib/spree/core/controller_helpers/locale_spec.rbindex 297d17b267..5796d8c789 100644--- a/core/spec/lib/spree/core/controller_helpers/locale_spec.rb+++ b/core/spec/lib/spree/core/controller_helpers/locale_spec.rb@@ -67,9 +67,9 @@ describe Spree::Core::ControllerHelpers::Locale, type: :controller doendcontext 'with I18n.default_locale set' do- before { I18n.default_locale = :de }-- after { I18n.default_locale = :en }+ before do+ allow(I18n).to receive(:default_locale).and_return(:de)+ endit 'fallbacks to the default application locale' doexpect(controller.current_locale.to_s).to eq('de')@@ -95,15 +95,17 @@ describe Spree::Core::ControllerHelpers::Locale, type: :controller dolet!(:store) { create :store, default: true, default_locale: 'en', supported_locales: 'en,de,fr' }context 'same as store default locale' do- before { I18n.locale = :en }+ before do+ allow(I18n).to receive(:locale).and_return(:en)+ endit { expect(controller.locale_param).to eq(nil) }endcontext 'different than store locale' do- before { I18n.locale = :de }-- after { I18n.locale = :en }+ before do+ allow(I18n).to receive(:locale).and_return(:de)+ endit { expect(controller.locale_param).to eq('de') }enddiff --git a/core/spec/lib/spree/localized_number_spec.rb b/core/spec/lib/spree/localized_number_spec.rbindex 584132fbe1..8db888d2c9 100644--- a/core/spec/lib/spree/localized_number_spec.rb+++ b/core/spec/lib/spree/localized_number_spec.rb@@ -4,12 +4,11 @@ describe Spree::LocalizedNumber docontext '.parse' dobefore doI18n.enforce_available_locales = false- I18n.locale = I18n.default_locale+ allow(I18n).to receive(:locale).and_return(I18n.default_locale)I18n.backend.store_translations(:de, number: { currency: { format: { delimiter: '.', separator: ',' } } })endafter do- I18n.locale = I18n.default_localeI18n.enforce_available_locales = trueend@@ -21,21 +20,25 @@ describe Spree::LocalizedNumber docontext 'with decimal comma' doit 'captures the proper amount for a formatted price' do- I18n.locale = :de+ allow(I18n).to receive(:locale).and_return(:de)+ allow(I18n.config).to receive(:locale).and_return(:de)+expect(subject.class.parse('1.599,99')).to eq 1599.99endendcontext 'with a numeric price' doit 'uses the price as is' do- I18n.locale = :de+ allow(I18n).to receive(:locale).and_return(:de)+ allow(I18n.config).to receive(:locale).and_return(:de)+expect(subject.class.parse(1599.99)).to eq 1599.99endendcontext 'string argument' doit 'is not modified' do- I18n.locale = :de+ allow(I18n).to receive(:locale).and_return(:de)number = '1.599,99'number_bak = number.dupsubject.class.parse(number)diff --git a/core/spec/models/spree/payment_spec.rb b/core/spec/models/spree/payment_spec.rbindex 37dba7872c..9dcf0e2470 100644--- a/core/spec/models/spree/payment_spec.rb+++ b/core/spec/models/spree/payment_spec.rb@@ -855,12 +855,10 @@ describe Spree::Payment, type: :model docontext 'when the locale uses a coma as a decimal separator' dobefore doI18n.backend.store_translations(:fr, number: { currency: { format: { delimiter: ' ', separator: ',' } } })- I18n.locale = :fr- subject.amount = amount- end+ allow(I18n).to receive(:locale).and_return(:fr)+ allow(I18n.config).to receive(:locale).and_return(:fr)- after do- I18n.locale = I18n.default_locale+ subject.amount = amountendcontext 'amount is a decimal' dodiff --git a/emails/spec/mailers/spree/order_mailer_spec.rb b/emails/spec/mailers/spree/order_mailer_spec.rbindex 17e1eb21d4..0c84696fa8 100644--- a/emails/spec/mailers/spree/order_mailer_spec.rb+++ b/emails/spec/mailers/spree/order_mailer_spec.rb@@ -196,7 +196,9 @@ describe Spree::OrderMailer, type: :mailer doendcontext 'via I18n' do- before { I18n.locale = :'pt-BR' }+ before do+ allow(I18n).to receive(:locale).and_return(:'pt-BR')+ endit_behaves_like 'translates emails'end