Skip to content

Commit

Permalink
Reorder I18n backends in with_translations helper
Browse files Browse the repository at this point in the history
The `with_translations` helper allows translations to be setup for a
method under test. A recent change (thoughtbot#772) added a backend chain to
ensure this helper won't break other spec by replacing all translations
and causing "missing_translations" failures.

This changes the order of the I18n backends so that specs will first use
the translations provided to the `with_translations` block and then
fallback to the default translations. Otherwise, there would be no way
to override the default translations in test cases.
  • Loading branch information
nburkley committed Mar 24, 2017
1 parent 182ad50 commit 94e7b63
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spec/support/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def with_translations(locale, translations)
new_backend = I18n::Backend::KeyValue.new({}, true)
new_backend.store_translations(locale, translations)

I18n.backend = I18n::Backend::Chain.new(original_backend, new_backend)
I18n.backend = I18n::Backend::Chain.new(new_backend, original_backend)

yield
ensure
Expand Down

0 comments on commit 94e7b63

Please sign in to comment.