Permalink
Browse files

Add a test case for layout nil.

  • Loading branch information...
1 parent c82fd8f commit dd0275e46314b6c4cddb1ae438ce1390d13aa53c @josevalim josevalim committed with avakhov Dec 20, 2011
Showing with 16 additions and 1 deletion.
  1. +1 −0 actionpack/lib/abstract_controller/layouts.rb
  2. +15 −1 actionpack/test/abstract/layouts_test.rb
@@ -249,6 +249,7 @@ def conditional_layout?
# Symbol:: call the method specified by the symbol, which will return the template name
# false:: There is no layout
# true:: raise an ArgumentError
+ # nil:: Force default layout behavior with inheritance
#
# ==== Parameters
# * <tt>layout</tt> - The layout to use.
@@ -14,7 +14,10 @@ class Base < AbstractController::Base
"layouts/overwrite.erb" => "Overwrite <%= yield %>",
"layouts/with_false_layout.erb" => "False Layout <%= yield %>",
"abstract_controller_tests/layouts/with_string_implied_child.erb" =>
- "With Implied <%= yield %>"
+ "With Implied <%= yield %>",
+ "abstract_controller_tests/layouts/with_grand_child_of_implied.erb" =>
+ "With Grand Child <%= yield %>"
+
)]
end
@@ -64,6 +67,10 @@ class WithStringImpliedChild < WithString
class WithChildOfImplied < WithStringImpliedChild
end
+ class WithGrandChildOfImplied < WithStringImpliedChild
+ layout nil
+ end
+
class WithProc < Base
layout proc { |c| "overwrite" }
@@ -299,6 +306,13 @@ class TestBase < ActiveSupport::TestCase
assert_equal "With Implied Hello string!", controller.response_body
end
+ test "when a grandchild has nil layout specified, the child has an implied layout, and the " \
+ "parent has specified a layout, use the child controller layout" do
+ controller = WithGrandChildOfImplied.new
+ controller.process(:index)
+ assert_equal "With Grand Child Hello string!", controller.response_body
+ end
+
test "raises an exception when specifying layout true" do
assert_raises ArgumentError do
Object.class_eval do

0 comments on commit dd0275e

Please sign in to comment.