aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/translation_helper_test.rb
diff options
context:
space:
mode:
authorlest <just.lest@gmail.com>2011-11-17 18:29:55 +0300
committerJon Leighton <j@jonathanleighton.com>2011-11-17 23:07:39 +0000
commite8d57f361a9982382f75449ec0d65d6c798b9ce2 (patch)
tree1d170b34597a5abdc55c650a3306935081f6b524 /actionpack/test/template/translation_helper_test.rb
parent1079724fe643fe63e6d58a37274c2cf0ff172a8b (diff)
downloadrails-e8d57f361a9982382f75449ec0d65d6c798b9ce2.tar.gz
rails-e8d57f361a9982382f75449ec0d65d6c798b9ce2.tar.bz2
rails-e8d57f361a9982382f75449ec0d65d6c798b9ce2.zip
_html translation should escape interpolated arguments
Diffstat (limited to 'actionpack/test/template/translation_helper_test.rb')
-rw-r--r--actionpack/test/template/translation_helper_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/test/template/translation_helper_test.rb b/actionpack/test/template/translation_helper_test.rb
index cd9f54e04c..cabb29cfad 100644
--- a/actionpack/test/template/translation_helper_test.rb
+++ b/actionpack/test/template/translation_helper_test.rb
@@ -17,6 +17,7 @@ class TranslationHelperTest < ActiveSupport::TestCase
:hello => '<a>Hello World</a>',
:html => '<a>Hello World</a>',
:hello_html => '<a>Hello World</a>',
+ :interpolated_html => '<a>Hello %{word}</a>',
:array_html => %w(foo bar),
:array => %w(foo bar)
}
@@ -83,6 +84,11 @@ class TranslationHelperTest < ActiveSupport::TestCase
assert translate(:'translations.hello_html').html_safe?
end
+ def test_translate_escapes_interpolations_in_translations_with_a_html_suffix
+ assert_equal '<a>Hello &lt;World&gt;</a>', translate(:'translations.interpolated_html', :word => '<World>')
+ assert_equal '<a>Hello &lt;World&gt;</a>', translate(:'translations.interpolated_html', :word => stub(:to_s => "<World>"))
+ end
+
def test_translation_returning_an_array_ignores_html_suffix
assert_equal ["foo", "bar"], translate(:'translations.array_html')
end