Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes ActionController::Rendering#with_defaults #28352

Merged
merged 1 commit into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions actionpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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*
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def new(env = {})

# 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.
Expand Down
10 changes: 10 additions & 0 deletions actionpack/test/controller/renderer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down