aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-04-20 19:47:16 -0400
committerJon Moss <me@jonathanmoss.me>2016-04-20 19:47:16 -0400
commit7bd2f9177342c57a81880425ab134945aea6fbd9 (patch)
treecce2c3d9891763a4cdfd3fd0b5e63c152e7eede9
parent115efeb036d4d56186ba7b0b64750cdc57471b59 (diff)
downloadrails-7bd2f9177342c57a81880425ab134945aea6fbd9.tar.gz
rails-7bd2f9177342c57a81880425ab134945aea6fbd9.tar.bz2
rails-7bd2f9177342c57a81880425ab134945aea6fbd9.zip
Fix ApplicationController.renderer.defaults.merge!
Previously, users were trying to modify a frozen Hash. Includes a regression test :) Fixes #22975
-rw-r--r--actionpack/lib/action_controller/renderer.rb2
-rw-r--r--actionpack/test/controller/renderer_test.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/renderer.rb b/actionpack/lib/action_controller/renderer.rb
index e4d19e9dba..2775a24e56 100644
--- a/actionpack/lib/action_controller/renderer.rb
+++ b/actionpack/lib/action_controller/renderer.rb
@@ -45,7 +45,7 @@ module ActionController
}.freeze
# Create a new renderer instance for a specific controller class.
- def self.for(controller, env = {}, defaults = DEFAULTS)
+ def self.for(controller, env = {}, defaults = DEFAULTS.dup)
new(controller, env, defaults)
end
diff --git a/actionpack/test/controller/renderer_test.rb b/actionpack/test/controller/renderer_test.rb
index 16d24fa82a..372c09bc23 100644
--- a/actionpack/test/controller/renderer_test.rb
+++ b/actionpack/test/controller/renderer_test.rb
@@ -87,6 +87,14 @@ class RendererTest < ActiveSupport::TestCase
assert_equal "<p>1\n<br />2</p>", render[inline: '<%= simple_format "1\n2" %>']
end
+ test 'rendering with user specified defaults' do
+ ApplicationController.renderer.defaults.merge!({ hello: 'hello', https: true })
+ renderer = ApplicationController.renderer.new
+ content = renderer.render inline: '<%= request.ssl? %>'
+
+ assert_equal 'true', content
+ end
+
private
def render
@render ||= ApplicationController.renderer.method(:render)