aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
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/controller
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/controller')
-rw-r--r--actionpack/test/controller/layout_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index 71bcfd664e..a61a1fe99d 100644
--- a/actionpack/test/controller/layout_test.rb
+++ b/actionpack/test/controller/layout_test.rb
@@ -94,6 +94,18 @@ class HasOwnLayoutController < LayoutTest
layout 'item'
end
+class HasNilLayoutSymbol < LayoutTest
+ layout :nilz
+
+ def nilz
+ nil
+ end
+end
+
+class HasNilLayoutProc < LayoutTest
+ layout proc { |c| nil }
+end
+
class PrependsViewPathController < LayoutTest
def hello
prepend_view_path File.dirname(__FILE__) + '/../fixtures/layout_tests/alt/'
@@ -142,6 +154,18 @@ class LayoutSetInResponseTest < ActionController::TestCase
assert_template :layout => "layouts/item"
end
+ def test_layout_symbol_set_in_controller_returning_nil_falls_back_to_default
+ @controller = HasNilLayoutSymbol.new
+ get :hello
+ assert_template layout: "layouts/layout_test"
+ end
+
+ def test_layout_proc_set_in_controller_returning_nil_falls_back_to_default
+ @controller = HasNilLayoutProc.new
+ get :hello
+ assert_template layout: "layouts/layout_test"
+ end
+
def test_layout_only_exception_when_included
@controller = OnlyLayoutController.new
get :hello