aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/translation_helper_test.rb
diff options
context:
space:
mode:
authorSergey Parizhskiy <parizhskiy@gmail.com>2011-11-28 17:33:23 +0200
committerSergey Parizhskiy <parizhskiy@gmail.com>2011-11-28 17:33:23 +0200
commite2e2d6298ebd9c67d0dc14c1e3481a59a4edf5d2 (patch)
tree83297628700ed0dc8ac8bdfb60aae8645a517c32 /actionpack/test/template/translation_helper_test.rb
parent493cf44682c19bd69eb2463d260c3bf29c7a23d7 (diff)
parent6d05c793cafe79860bcbb469d6c46c83c531ab34 (diff)
downloadrails-e2e2d6298ebd9c67d0dc14c1e3481a59a4edf5d2.tar.gz
rails-e2e2d6298ebd9c67d0dc14c1e3481a59a4edf5d2.tar.bz2
rails-e2e2d6298ebd9c67d0dc14c1e3481a59a4edf5d2.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'actionpack/test/template/translation_helper_test.rb')
-rw-r--r--actionpack/test/template/translation_helper_test.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/actionpack/test/template/translation_helper_test.rb b/actionpack/test/template/translation_helper_test.rb
index cd9f54e04c..397de9c2ce 100644
--- a/actionpack/test/template/translation_helper_test.rb
+++ b/actionpack/test/template/translation_helper_test.rb
@@ -17,8 +17,13 @@ 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)
+ :array => %w(foo bar),
+ :count_html => {
+ :one => '<a>One %{count}</a>',
+ :other => '<a>Other %{count}</a>'
+ }
}
)
@view = ::ActionView::Base.new(ActionController::Base.view_paths, {})
@@ -83,6 +88,17 @@ 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_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