Skip to content

Commit

Permalink
Ruby 1.9 compat: change encoding of action_view/renderable to utf-8, …
Browse files Browse the repository at this point in the history
…so erb templates can use utf-8 properly

[#1881 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
libc authored and jeremy committed Feb 6, 2009
1 parent ae36fce commit b1c1e3d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 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
Expand Down
2 changes: 2 additions & 0 deletions actionpack/test/fixtures/test/utf8.html.erb
@@ -0,0 +1,2 @@
Русский текст
日本語のテキスト
9 changes: 9 additions & 0 deletions actionpack/test/template/render_test.rb
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'abstract_unit'
require 'controller/fake_models'

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b1c1e3d

Please sign in to comment.