提交 296830ed 编写于 作者: R Rafael Mendonça França

Merge pull request #10262 from printercu/patch-3

Avoid leak into controller's action_methods
......@@ -309,6 +309,7 @@ def _write_layout_method # :nodoc:
RUBY
when Proc
define_method :_layout_from_proc, &_layout
protected :_layout_from_proc
<<-RUBY
result = _layout_from_proc(#{_layout.arity == 0 ? '' : 'self'})
return #{default_behavior} if result.nil?
......
......@@ -8,6 +8,8 @@ class Base < AbstractController::Base
include AbstractController::Rendering
include AbstractController::Layouts
abstract!
self.view_paths = [ActionView::FixtureResolver.new(
"layouts/hello.erb" => "With String <%= yield %>",
"layouts/hello_override.erb" => "With Override <%= yield %>",
......@@ -251,6 +253,10 @@ class TestBase < ActiveSupport::TestCase
assert_equal "Hello nil!", controller.response_body
end
test "when layout is specified as a proc, do not leak any methods into controller's action_methods" do
assert_equal Set.new(['index']), WithProc.action_methods
end
test "when layout is specified as a proc, call it and use the layout returned" do
controller = WithProc.new
controller.process(:index)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册