Skip to content

Commit

Permalink
Merge branch 'test-ordering-issue' into deep-merges-with-chain-lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
julik committed Nov 12, 2014
2 parents d9e9113 + 981b95a commit 8db944b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/i18n_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,25 @@ def call(exception, locale, key, options); key; end
I18n.config.enforce_available_locales = false
end
end


def inspect_config
vars = I18n.config.class.class_variables
table = vars.inject({}) do | m, varname |
m.merge varname => I18n.config.class.class_variable_get(varname)
end
puts table.inspect
end

test 'I18n.reload! reloads the set of locales that are enforced' do
begin
# Clear the backend that affects the available locales and somehow can remain
# set from the last running test.
# For instance, it contains enough translations to cause a false positive with
# this test when ran with --seed=50992
I18n.backend = I18n::Backend::Simple.new

assert !I18n.available_locales.include?(:de), "Available locales should not include :de at this point"

I18n.enforce_available_locales = true

assert_raise(I18n::InvalidLocale) { I18n.default_locale = :de }
Expand All @@ -406,7 +422,11 @@ def call(exception, locale, key, options); key; end
store_translations(:en, :foo => 'Foo in :en')
store_translations(:de, :foo => 'Foo in :de')
store_translations(:pl, :foo => 'Foo in :pl')


assert I18n.available_locales.include?(:de), ":de should now be allowed"
assert I18n.available_locales.include?(:en), ":en should now be allowed"
assert I18n.available_locales.include?(:pl), ":pl should now be allowed"

assert_nothing_raised { I18n.default_locale = I18n.locale = :en }
assert_nothing_raised { I18n.default_locale = I18n.locale = :de }
assert_nothing_raised { I18n.default_locale = I18n.locale = :pl }
Expand Down

0 comments on commit 8db944b

Please sign in to comment.