aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-04-08 20:22:07 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-04-08 20:22:07 -0700
commit4691c696b0cda985c5d868312555cd538328a99c (patch)
tree54de65952509e791ddb542879fa270e3384fc0aa /actionpack/test/template
parentbd2bf5390d892a1c11bcaa2143f557b82611015e (diff)
downloadrails-4691c696b0cda985c5d868312555cd538328a99c.tar.gz
rails-4691c696b0cda985c5d868312555cd538328a99c.tar.bz2
rails-4691c696b0cda985c5d868312555cd538328a99c.zip
Expect an incompatible encoding exception when a template with a magic comment renders a partial without one and its source encoding doesn't match the default external encoding
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/render_test.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 647c673902..c9a50da418 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -283,7 +283,7 @@ class LazyViewRenderTest < ActiveSupport::TestCase
with_external_encoding Encoding::ASCII_8BIT do
result = @view.render(:file => "test/utf8_magic.html.erb", :layouts => "layouts/yield")
assert_equal Encoding::UTF_8, result.encoding
- assert_equal "Русский текст\nUTF-8\nUTF-8\nUTF-8\n", result
+ assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result
end
end
@@ -291,7 +291,7 @@ class LazyViewRenderTest < ActiveSupport::TestCase
with_external_encoding Encoding::UTF_8 do
result = @view.render(:file => "test/utf8.html.erb", :layouts => "layouts/yield")
assert_equal Encoding::UTF_8, result.encoding
- assert_equal "Русский текст\nUTF-8\nUTF-8\nUTF-8\n", result
+ assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result
end
end
@@ -306,6 +306,17 @@ class LazyViewRenderTest < ActiveSupport::TestCase
end
end
+ def test_render_utf8_template_with_partial_with_incompatible_encoding
+ with_external_encoding Encoding::SJIS do
+ begin
+ result = @view.render(:file => "test/utf8_magic_with_bare_partial.html.erb", :layouts => "layouts/yield")
+ flunk 'Should have raised incompatible encoding error'
+ rescue ActionView::Template::Error => error
+ assert_match 'invalid byte sequence in Shift_JIS', error.original_exception.message
+ end
+ end
+ end
+
def with_external_encoding(encoding)
old, Encoding.default_external = Encoding.default_external, encoding
yield