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.
This commit is contained in:
Javi Martín
2019-06-20 01:35:51 +02:00
parent da121ebc53
commit 7be72df5bf
4 changed files with 1 additions and 19 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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])

View File

@@ -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