diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-12 15:39:17 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-12 15:39:17 -0200 |
commit | 76f6524538a50b4e3ede3d1ae58fcfbac3e77a91 (patch) | |
tree | aa5a2db6a29840b66c691f5ecddaa7c2203e76b7 /actionpack/test/abstract | |
parent | 68ce508e180eaed9539d2bea102861f9a56f50e6 (diff) | |
parent | fde7344542a76e7f1f95a2265ac5480a1ef9aeed (diff) | |
download | rails-76f6524538a50b4e3ede3d1ae58fcfbac3e77a91.tar.gz rails-76f6524538a50b4e3ede3d1ae58fcfbac3e77a91.tar.bz2 rails-76f6524538a50b4e3ede3d1ae58fcfbac3e77a91.zip |
Merge pull request #11790 from printercu/patch-3
ActionController#translate supports symbols
Diffstat (limited to 'actionpack/test/abstract')
-rw-r--r-- | actionpack/test/abstract/translation_test.rb | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/actionpack/test/abstract/translation_test.rb b/actionpack/test/abstract/translation_test.rb index 4fdc480b43..8289252dfc 100644 --- a/actionpack/test/abstract/translation_test.rb +++ b/actionpack/test/abstract/translation_test.rb @@ -9,6 +9,22 @@ module AbstractController class TranslationControllerTest < ActiveSupport::TestCase def setup @controller = TranslationController.new + I18n.backend.store_translations(:en, { + one: { + two: 'bar', + }, + abstract_controller: { + testing: { + translation: { + index: { + foo: 'bar', + }, + no_action: 'no_action_tr', + }, + }, + }, + }) + @controller.stubs(action_name: :index) end def test_action_controller_base_responds_to_translate @@ -28,16 +44,19 @@ module AbstractController end def test_lazy_lookup - expected = 'bar' - @controller.stubs(action_name: :index) - I18n.stubs(:translate).with('abstract_controller.testing.translation.index.foo').returns(expected) - assert_equal expected, @controller.t('.foo') + assert_equal 'bar', @controller.t('.foo') + end + + def test_lazy_lookup_with_symbol + assert_equal 'bar', @controller.t(:'.foo') + end + + def test_lazy_lookup_fallback + assert_equal 'no_action_tr', @controller.t(:'.no_action') end def test_default_translation - key, expected = 'one.two', 'bar' - I18n.stubs(:translate).with(key).returns(expected) - assert_equal expected, @controller.t(key) + assert_equal 'bar', @controller.t('one.two') end def test_localize |