diff options
author | wycats <wycats@gmail.com> | 2010-05-30 11:07:34 +0200 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-03 23:32:10 +1000 |
commit | fad29012af65e995a492d0159a50a3fcd98d68f4 (patch) | |
tree | a1abc9af858c6f8660ae67a0e11e685fb0f40f41 /actionpack/test/template/template_test.rb | |
parent | 2740943634fe151fb3fb87e2af7881a93f5dd6b5 (diff) | |
download | rails-fad29012af65e995a492d0159a50a3fcd98d68f4.tar.gz rails-fad29012af65e995a492d0159a50a3fcd98d68f4.tar.bz2 rails-fad29012af65e995a492d0159a50a3fcd98d68f4.zip |
Update template to allow handlers to more cleanly handle encodings (ht: nex3)
Diffstat (limited to 'actionpack/test/template/template_test.rb')
-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 |