aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-12 15:39:17 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-12 15:39:17 -0200
commit76f6524538a50b4e3ede3d1ae58fcfbac3e77a91 (patch)
treeaa5a2db6a29840b66c691f5ecddaa7c2203e76b7 /actionpack/test
parent68ce508e180eaed9539d2bea102861f9a56f50e6 (diff)
parentfde7344542a76e7f1f95a2265ac5480a1ef9aeed (diff)
downloadrails-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')
-rw-r--r--actionpack/test/abstract/translation_test.rb33
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