aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/translation_helper_test.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-11-19 13:19:20 +0000
committerJon Leighton <j@jonathanleighton.com>2011-11-19 13:28:07 +0000
commit603a679e87d0317957eb44ce3928d593a0c50bb5 (patch)
tree739959ff9cbd0a6f7d8f3d879591d8b393974635 /actionpack/test/template/translation_helper_test.rb
parent86b5e81e8ac6590995e1e0643959fe8f527b4e49 (diff)
downloadrails-603a679e87d0317957eb44ce3928d593a0c50bb5.tar.gz
rails-603a679e87d0317957eb44ce3928d593a0c50bb5.tar.bz2
rails-603a679e87d0317957eb44ce3928d593a0c50bb5.zip
Don't html-escape the :count option to translate if it's a Numeric. Fixes #3685.
Diffstat (limited to 'actionpack/test/template/translation_helper_test.rb')
-rw-r--r--actionpack/test/template/translation_helper_test.rb12
1 files changed, 11 insertions, 1 deletions
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 => '<a>Hello World</a>',
:interpolated_html => '<a>Hello %{word}</a>',
:array_html => %w(foo bar),
- :array => %w(foo bar)
+ :array => %w(foo bar),
+ :count_html => {
+ :one => '<a>One %{count}</a>',
+ :other => '<a>Other %{count}</a>'
+ }
}
)
@view = ::ActionView::Base.new(ActionController::Base.view_paths, {})
@@ -89,6 +93,12 @@ class TranslationHelperTest < ActiveSupport::TestCase
assert_equal '<a>Hello &lt;World&gt;</a>', translate(:'translations.interpolated_html', :word => stub(:to_s => "<World>"))
end
+ def test_translate_with_html_count
+ assert_equal '<a>One 1</a>', translate(:'translations.count_html', :count => 1)
+ assert_equal '<a>Other 2</a>', translate(:'translations.count_html', :count => 2)
+ assert_equal '<a>Other &lt;One&gt;</a>', translate(:'translations.count_html', :count => '<One>')
+ end
+
def test_translation_returning_an_array_ignores_html_suffix
assert_equal ["foo", "bar"], translate(:'translations.array_html')
end