Permalink
Browse files

Ruby 1.9 compat: change encoding of action_view/renderable to utf-8, …

…so erb templates can use utf-8 properly

[#1881 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent ae36fce commit b1c1e3deb7d752292abaff34ba66a3eae030d252 @libc libc committed with jeremy Feb 5, 2009
View
2 actionpack/lib/action_view/renderable.rb
@@ -1,3 +1,5 @@
+# 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
View
2 actionpack/test/fixtures/test/utf8.html.erb
@@ -0,0 +1,2 @@
+Русский текст
+日本語のテキスト
View
9 actionpack/test/template/render_test.rb
@@ -1,3 +1,4 @@
+# encoding: utf-8
require 'abstract_unit'
require 'controller/fake_models'
@@ -204,6 +205,14 @@ def test_render_with_nested_layout
assert_equal %(<title>title</title>\n<div id="column">column</div>\n<div id="content">content</div>\n),
@view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield")
end
+
+ if '1.9'.respond_to?(:force_encoding)
+ def test_render_utf8_template
+ result = @view.render(:file => "test/utf8.html.erb", :layouts => "layouts/yield")
+ assert_equal "Русский текст\n日本語のテキスト", result
+ assert_equal Encoding::UTF_8, result.encoding
+ end
+ end
end
class CachedViewRenderTest < Test::Unit::TestCase

0 comments on commit b1c1e3d

Please sign in to comment.