Skip to content

Commit

Permalink
Merge pull request #30493 from koic/fix_cant_modify_frozen_string_err…
Browse files Browse the repository at this point in the history
…or_in_ac_rendering

Fix `can't modify frozen String` error in AC::Rendering
  • Loading branch information
kamipo committed Sep 2, 2017
2 parents ea0afe9 + 3ee59ee commit d24efb7
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 @@ -40,7 +40,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 d24efb7

Please sign in to comment.