Skip to content

Commit

Permalink
Fix can't modify frozen String error in AC::Rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Sep 2, 2017
1 parent c2b2a8c commit 3ee59ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/metal/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def render(*args) #:nodoc:
def render_to_string(*)
result = super
if result.respond_to?(:each)
string = ""
string = "".dup
result.each { |r| string << r }
string
else
Expand Down
12 changes: 12 additions & 0 deletions actionpack/test/controller/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,18 @@ def test_access_to_logger_in_view
end
end

class ActionControllerRenderTest < ActionController::TestCase
class MinimalController < ActionController::Metal
include AbstractController::Rendering
include ActionController::Rendering
end

def test_direct_render_to_string_with_body
mc = MinimalController.new
assert_equal "Hello world!", mc.render_to_string(body: ["Hello world!"])
end
end

class ActionControllerBaseRenderTest < ActionController::TestCase
def test_direct_render_to_string
ac = ActionController::Base.new()
Expand Down

0 comments on commit 3ee59ee

Please sign in to comment.