diff options
author | wycats <wycats@gmail.com> | 2010-05-30 11:07:34 +0200 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-05-30 11:37:35 +0200 |
commit | 0078df6b54e595421bb486613f7bc3693250b592 (patch) | |
tree | a1abc9af858c6f8660ae67a0e11e685fb0f40f41 /actionpack/test/template | |
parent | 19d8c8cbe4aae570e3b48080e3182e5634aa7aec (diff) | |
download | rails-0078df6b54e595421bb486613f7bc3693250b592.tar.gz rails-0078df6b54e595421bb486613f7bc3693250b592.tar.bz2 rails-0078df6b54e595421bb486613f7bc3693250b592.zip |
Update template to allow handlers to more cleanly handle encodings (ht: nex3)
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/template_test.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index 995d728d50..18e0e83ec3 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -114,10 +114,12 @@ class TestERBTemplate < ActiveSupport::TestCase end def test_encoding_can_be_specified_with_magic_comment_in_erb - @template = new_template("<%# encoding: ISO-8859-1 %>hello \xFCmlat") - result = render - assert_equal Encoding::UTF_8, render.encoding - assert_equal "hello \u{fc}mlat", render + with_external_encoding Encoding::UTF_8 do + @template = new_template("<%# encoding: ISO-8859-1 %>hello \xFCmlat") + result = render + assert_equal Encoding::UTF_8, render.encoding + assert_equal "hello \u{fc}mlat", render + end end def test_error_when_template_isnt_valid_utf8 @@ -126,5 +128,12 @@ class TestERBTemplate < ActiveSupport::TestCase render end end + + def with_external_encoding(encoding) + old, Encoding.default_external = Encoding.default_external, encoding + yield + ensure + Encoding.default_external = old + end end end
\ No newline at end of file |