From 7be72df5bf0abd7d82499412e5b2a9af8b9cfcb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 20 Jun 2019 01:35:51 +0200 Subject: [PATCH] Remove redundant I18n resets in `after` blocks We already configure `I18n.locale` and we reset Globalize's fallbacks before every test. On the other hand, RSpec automatically resets anything which is stub with `allow`, so there's no need to use `and_call_original` in an `after` block. --- spec/features/remote_translations_spec.rb | 6 ------ spec/models/budget_spec.rb | 4 ---- spec/models/concerns/globalizable.rb | 6 ------ spec/spec_helper.rb | 4 +--- 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/spec/features/remote_translations_spec.rb b/spec/features/remote_translations_spec.rb index 92a16d1c3..dd6d3a78a 100644 --- a/spec/features/remote_translations_spec.rb +++ b/spec/features/remote_translations_spec.rb @@ -10,12 +10,6 @@ describe "Remote Translations" do and_return(available_locales_response) end - after do - allow(I18n).to receive(:available_locales).and_call_original - allow(I18n.fallbacks).to receive(:[]).and_call_original - Globalize.set_fallbacks_to_all_available_locales - end - describe "Display remote translation button when locale is included in microsoft translate client" do context "with locale that has :en fallback" do diff --git a/spec/models/budget_spec.rb b/spec/models/budget_spec.rb index 1ea1d534a..f2744c8fe 100644 --- a/spec/models/budget_spec.rb +++ b/spec/models/budget_spec.rb @@ -274,10 +274,6 @@ describe Budget do end describe "#formatted_amount" do - after do - I18n.locale = :en - end - it "correctly formats Euros with Spanish" do budget.update(currency_symbol: "€") I18n.locale = :es diff --git a/spec/models/concerns/globalizable.rb b/spec/models/concerns/globalizable.rb index b63734117..7dc88543b 100644 --- a/spec/models/concerns/globalizable.rb +++ b/spec/models/concerns/globalizable.rb @@ -21,12 +21,6 @@ shared_examples_for "globalizable" do |factory_name| end end - after do - allow(I18n).to receive(:available_locales).and_call_original - allow(I18n.fallbacks).to receive(:[]).and_call_original - Globalize.set_fallbacks_to_all_available_locales - end - context "With a defined fallback" do before do allow(I18n.fallbacks).to receive(:[]).and_return([:fr, :es]) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a85ff40d4..698e52c0b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -45,9 +45,7 @@ RSpec.configure do |config| DatabaseCleaner.strategy = :transaction I18n.locale = :en Globalize.locale = I18n.locale - unless %i[controller feature request].include? example.metadata[:type] - Globalize.set_fallbacks_to_all_available_locales - end + Globalize.set_fallbacks_to_all_available_locales load Rails.root.join("db", "seeds.rb").to_s Setting["feature.user.skip_verification"] = nil end