diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-02 14:08:46 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-02 14:08:46 +0900 |
commit | d24efb79cc438987358f0d4fa3b1da8615a8ed51 (patch) | |
tree | e8ea50bbde477d4c49adab8c06096f128bab9ace /actionpack | |
parent | ea0afe9de24f175e125ab1647f91cf52bcfe536b (diff) | |
parent | 3ee59eec2ffd07d1e4b12ef047495fb9d1ee13ce (diff) | |
download | rails-d24efb79cc438987358f0d4fa3b1da8615a8ed51.tar.gz rails-d24efb79cc438987358f0d4fa3b1da8615a8ed51.tar.bz2 rails-d24efb79cc438987358f0d4fa3b1da8615a8ed51.zip |
Merge pull request #30493 from koic/fix_cant_modify_frozen_string_error_in_ac_rendering
Fix `can't modify frozen String` error in AC::Rendering
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/rendering.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 456a7cf71c..6d181e6456 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -40,7 +40,7 @@ module ActionController def render_to_string(*) result = super if result.respond_to?(:each) - string = "" + string = "".dup result.each { |r| string << r } string else diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 3619afc513..1ca668b9b1 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -606,6 +606,18 @@ class MetalRenderTest < ActionController::TestCase 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() |