From e8d57f361a9982382f75449ec0d65d6c798b9ce2 Mon Sep 17 00:00:00 2001 From: lest Date: Thu, 17 Nov 2011 18:29:55 +0300 Subject: _html translation should escape interpolated arguments --- actionpack/test/template/translation_helper_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack/test/template/translation_helper_test.rb') 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 => 'Hello World', :html => 'Hello World', :hello_html => 'Hello World', + :interpolated_html => 'Hello %{word}', :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 'Hello <World>', translate(:'translations.interpolated_html', :word => '') + assert_equal 'Hello <World>', translate(:'translations.interpolated_html', :word => stub(:to_s => "")) + end + def test_translation_returning_an_array_ignores_html_suffix assert_equal ["foo", "bar"], translate(:'translations.array_html') end -- cgit v1.2.3 From 603a679e87d0317957eb44ce3928d593a0c50bb5 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 19 Nov 2011 13:19:20 +0000 Subject: Don't html-escape the :count option to translate if it's a Numeric. Fixes #3685. --- actionpack/test/template/translation_helper_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'actionpack/test/template/translation_helper_test.rb') diff --git a/actionpack/test/template/translation_helper_test.rb b/actionpack/test/template/translation_helper_test.rb index cabb29cfad..397de9c2ce 100644 --- a/actionpack/test/template/translation_helper_test.rb +++ b/actionpack/test/template/translation_helper_test.rb @@ -19,7 +19,11 @@ class TranslationHelperTest < ActiveSupport::TestCase :hello_html => 'Hello World', :interpolated_html => 'Hello %{word}', :array_html => %w(foo bar), - :array => %w(foo bar) + :array => %w(foo bar), + :count_html => { + :one => 'One %{count}', + :other => 'Other %{count}' + } } ) @view = ::ActionView::Base.new(ActionController::Base.view_paths, {}) @@ -89,6 +93,12 @@ class TranslationHelperTest < ActiveSupport::TestCase assert_equal 'Hello <World>', translate(:'translations.interpolated_html', :word => stub(:to_s => "")) end + def test_translate_with_html_count + assert_equal 'One 1', translate(:'translations.count_html', :count => 1) + assert_equal 'Other 2', translate(:'translations.count_html', :count => 2) + assert_equal 'Other <One>', translate(:'translations.count_html', :count => '') + end + def test_translation_returning_an_array_ignores_html_suffix assert_equal ["foo", "bar"], translate(:'translations.array_html') end -- cgit v1.2.3