aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralpaca-tc <alpaca-tc@alpaca.tc>2017-03-08 18:54:52 +0900
committeralpaca-tc <alpaca-tc@alpaca.tc>2017-03-12 22:38:20 +0900
commitc5f8fe9379dc144a54ceb5663aa449d35d1bf405 (patch)
tree2fff48e6333d01bf8cc149b837b8e4971e971235
parent4cb8cbd80b0bfedc0fb7033c9f5c41a65312b644 (diff)
downloadrails-c5f8fe9379dc144a54ceb5663aa449d35d1bf405.tar.gz
rails-c5f8fe9379dc144a54ceb5663aa449d35d1bf405.tar.bz2
rails-c5f8fe9379dc144a54ceb5663aa449d35d1bf405.zip
Fixes ActionController::Rendering#with_defaults
`env` is undefined.
-rw-r--r--actionpack/CHANGELOG.md6
-rw-r--r--actionpack/lib/action_controller/renderer.rb2
-rw-r--r--actionpack/test/controller/renderer_test.rb10
3 files changed, 17 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 770bda1d44..a0cddbe709 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,9 @@
+* Fix `ActionController::Renderer#with_defaults` does not work
+
+ Fixes `NameError: undefined local variable or method `env'`.
+
+ *Hiroyuki Ishii*
+
* Added `#reverse_merge` and `#reverse_merge!` methods to `ActionController::Parameters`
*Edouard Chin*, *Mitsutaka Mimura*
diff --git a/actionpack/lib/action_controller/renderer.rb b/actionpack/lib/action_controller/renderer.rb
index e1441bd343..3d2edb5242 100644
--- a/actionpack/lib/action_controller/renderer.rb
+++ b/actionpack/lib/action_controller/renderer.rb
@@ -56,7 +56,7 @@ module ActionController
# Create a new renderer for the same controller but with new defaults.
def with_defaults(defaults)
- self.class.new controller, env, self.defaults.merge(defaults)
+ self.class.new controller, @env, self.defaults.merge(defaults)
end
# Accepts a custom Rack environment to render templates in.
diff --git a/actionpack/test/controller/renderer_test.rb b/actionpack/test/controller/renderer_test.rb
index 81b32a67b3..052c974d68 100644
--- a/actionpack/test/controller/renderer_test.rb
+++ b/actionpack/test/controller/renderer_test.rb
@@ -19,6 +19,16 @@ class RendererTest < ActiveSupport::TestCase
assert_equal controller, renderer.controller
end
+ test "creating with new defaults" do
+ renderer = ApplicationController.renderer
+
+ new_defaults = { https: true }
+ new_renderer = renderer.with_defaults(new_defaults).new
+ content = new_renderer.render(inline: "<%= request.ssl? %>")
+
+ assert_equal "true", content
+ end
+
test "rendering with a class renderer" do
renderer = ApplicationController.renderer
content = renderer.render template: "ruby_template"