aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract/layouts_test.rb
diff options
context:
space:
mode:
authorChris Nicola <chnicola@gmail.com>2012-12-07 15:55:54 -0800
committerChris Nicola <chnicola@gmail.com>2013-03-27 10:59:50 -0700
commitef27bba63d93453dee26e2decfca80659f2da735 (patch)
tree2b571c1f91eb951a3e09310e6702461e6ee8b3bb /actionpack/test/abstract/layouts_test.rb
parent0bc301ef7d8a2ded89d412fe4193594f0523fa99 (diff)
downloadrails-ef27bba63d93453dee26e2decfca80659f2da735.tar.gz
rails-ef27bba63d93453dee26e2decfca80659f2da735.tar.bz2
rails-ef27bba63d93453dee26e2decfca80659f2da735.zip
Provides standard layout lookup behavior for method and proc cases
When setting the layout either by referencing a method or supplying a Proc there is no way to fall back to the default lookup behavior if desired. This patch allows fallback to the layout lookup behavior when returning nil from the proc or method.
Diffstat (limited to 'actionpack/test/abstract/layouts_test.rb')
-rw-r--r--actionpack/test/abstract/layouts_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb
index 558a45b87f..70688d7267 100644
--- a/actionpack/test/abstract/layouts_test.rb
+++ b/actionpack/test/abstract/layouts_test.rb
@@ -79,6 +79,14 @@ module AbstractControllerTests
end
end
+ class WithProcReturningNil < Base
+ layout proc { |c| nil }
+
+ def index
+ render template: ActionView::Template::Text.new("Hello nil!")
+ end
+ end
+
class WithZeroArityProc < Base
layout proc { "overwrite" }
@@ -249,6 +257,12 @@ module AbstractControllerTests
assert_equal "Overwrite Hello proc!", controller.response_body
end
+ test "when layout is specified as a proc and the proc retuns nil, don't use a layout" do
+ controller = WithProcReturningNil.new
+ controller.process(:index)
+ assert_equal "Hello nil!", controller.response_body
+ end
+
test "when layout is specified as a proc without parameters it works just the same" do
controller = WithZeroArityProc.new
controller.process(:index)