From dd21d00eccd216b046b7e1ef7b0bd4e8bfd210c9 Mon Sep 17 00:00:00 2001 From: Eugene Pimenov Date: Thu, 5 Feb 2009 07:10:03 +0300 Subject: [PATCH] Ruby 1.9 compat: change encoding of action_view/renderable to utf-8, so erb templates can use utf-8 properly --- actionpack/lib/action_view/renderable.rb | 1 + actionpack/test/fixtures/test/utf8.html.erb | 2 ++ actionpack/test/template/render_test.rb | 7 +++++++ 3 files changed, 10 insertions(+), 0 deletions(-) create mode 100644 actionpack/test/fixtures/test/utf8.html.erb diff --git a/actionpack/lib/action_view/renderable.rb b/actionpack/lib/action_view/renderable.rb index 153e14f..122c8b2 100644 --- a/actionpack/lib/action_view/renderable.rb +++ b/actionpack/lib/action_view/renderable.rb @@ -1,3 +1,4 @@ +#-*- encoding: utf-8 -*- module ActionView # NOTE: The template that this mixin is being included into is frozen # so you cannot set or modify any instance variables diff --git a/actionpack/test/fixtures/test/utf8.html.erb b/actionpack/test/fixtures/test/utf8.html.erb new file mode 100644 index 0000000..0b4d19a --- /dev/null +++ b/actionpack/test/fixtures/test/utf8.html.erb @@ -0,0 +1,2 @@ +Русский текст +日本語のテキスト \ No newline at end of file diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index c7405d4..e1c4dec 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -204,6 +204,13 @@ module RenderTestCases assert_equal %(title\n
column
\n
content
\n), @view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield") end + +if RUBY_VERSION >= '1.9' + def test_render_utf8_template + assert_equal [1056, 1091, 1089, 1089, 1082, 1080, 1081, 32, 1090, 1077, 1082, 1089, 1090, 10, 26085, 26412, 35486, 12398, 12486, 12461, 12473, 12488].pack("U*"), + @view.render(:file => "test/utf8.html.erb", :layouts => "layouts/yield") + end +end end class CachedViewRenderTest < Test::Unit::TestCase -- 1.6.0.2.g2ebc0