Add locale to context registers

This commit is contained in:
Simon Eskildsen
2013-08-15 10:22:29 -04:00
parent 0a2f21386d
commit 40fba9ee6c
4 changed files with 29 additions and 17 deletions

View File

@@ -30,4 +30,8 @@ class I18nTest < Test::Unit::TestCase
@i18n.translate("doesnt_exist")
end
end
def test_sets_default_path_to_en
assert_equal I18n::DEFAULT_LOCALE, I18n.new.path
end
end

View File

@@ -143,4 +143,18 @@ class TemplateTest < Test::Unit::TestCase
assert_equal 'bar', t.parse('{{bar}}').render(drop)
assert_equal 'haha', t.parse("{{baz}}").render(drop)
end
end # TemplateTest
def test_sets_default_localization_in_context
t = Template.new(:locale => fixture("en_locale.yml"))
assert_instance_of I18n, t.registers[:locale]
assert_equal fixture("en_locale.yml"), t.registers[:locale].path
end
def test_sets_default_localization_in_context_with_quick_initialization
t = Template.parse('{{foo}}', :locale => fixture("en_locale.yml"))
assert_instance_of I18n, t.registers[:locale]
assert_equal fixture("en_locale.yml"), t.registers[:locale].path
end
end