test/i18n_test.rb in i18n-0.6.11 vs test/i18n_test.rb in i18n-0.7.0.beta1
- old
+ new
@@ -1,10 +1,11 @@
# encoding: utf-8
require 'test_helper'
class I18nTest < I18n::TestCase
def setup
+ super
store_translations(:en, :currency => { :format => { :separator => '.', :delimiter => ',', } })
store_translations(:nl, :currency => { :format => { :separator => ',', :delimiter => '.', } })
end
test "exposes its VERSION constant" do
@@ -35,10 +36,14 @@
ensure
I18n.default_locale = :en
end
end
+ test "default_locale= doesn't ignore junk" do
+ assert_raise(NoMethodError) { I18n.default_locale = Class }
+ end
+
test "raises an I18n::InvalidLocale exception when setting an unavailable default locale" do
begin
I18n.config.enforce_available_locales = true
assert_raise(I18n::InvalidLocale) { I18n.default_locale = :klingon }
ensure
@@ -55,10 +60,14 @@
assert_equal :de, I18n.locale
assert_equal :de, Thread.current[:i18n_config].locale
I18n.locale = :en
end
+ test "locale= doesn't ignore junk" do
+ assert_raise(NoMethodError) { I18n.locale = Class }
+ end
+
test "raises an I18n::InvalidLocale exception when setting an unavailable locale" do
begin
I18n.config.enforce_available_locales = true
assert_raise(I18n::InvalidLocale) { I18n.locale = :klingon }
ensure
@@ -375,8 +384,34 @@
begin
I18n.config.enforce_available_locales = false
assert_equal false, I18n.config.enforce_available_locales
ensure
I18n.config.enforce_available_locales = false
+ end
+ end
+
+ test 'I18n.reload! reloads the set of locales that are enforced' do
+ begin
+ I18n.enforce_available_locales = true
+
+ assert_raise(I18n::InvalidLocale) { I18n.default_locale = :de }
+ assert_raise(I18n::InvalidLocale) { I18n.locale = :de }
+
+ store_translations(:de, :foo => 'Foo in :de')
+
+ assert_raise(I18n::InvalidLocale) { I18n.default_locale = :de }
+ assert_raise(I18n::InvalidLocale) { I18n.locale = :de }
+
+ I18n.reload!
+
+ store_translations(:en, :foo => 'Foo in :en')
+ store_translations(:de, :foo => 'Foo in :de')
+ store_translations(:pl, :foo => 'Foo in :pl')
+
+ 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 }
+ ensure
+ I18n.enforce_available_locales = false
end
end
end