aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-07 08:00:45 -0800
committerJosé Valim <jose.valim@gmail.com>2011-12-07 08:00:45 -0800
commit0df2ef3ef4db161524d0d5eb275e41032b60db00 (patch)
tree24462bce4ec413cf4288f7d3b0bc108818064095 /actionpack/test/abstract
parent4f107384f02b1f122330d3e589a92a8fdd078e2e (diff)
parent18ceed201b37d91ad6598d0f8b3c010e6cc48b15 (diff)
downloadrails-0df2ef3ef4db161524d0d5eb275e41032b60db00.tar.gz
rails-0df2ef3ef4db161524d0d5eb275e41032b60db00.tar.bz2
rails-0df2ef3ef4db161524d0d5eb275e41032b60db00.zip
Merge pull request #3884 from sikachu/master-fix_layout
Allow layout fallback when using `layout` method
Diffstat (limited to 'actionpack/test/abstract')
-rw-r--r--actionpack/test/abstract/layouts_test.rb50
1 files changed, 49 insertions, 1 deletions
diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb
index 86208899f8..a5382a730d 100644
--- a/actionpack/test/abstract/layouts_test.rb
+++ b/actionpack/test/abstract/layouts_test.rb
@@ -141,6 +141,30 @@ module AbstractControllerTests
end
end
+ class WithOnlyConditional < WithStringImpliedChild
+ layout "overwrite", :only => :show
+
+ def index
+ render :template => ActionView::Template::Text.new("Hello index!")
+ end
+
+ def show
+ render :template => ActionView::Template::Text.new("Hello show!")
+ end
+ end
+
+ class WithExceptConditional < WithStringImpliedChild
+ layout "overwrite", :except => :show
+
+ def index
+ render :template => ActionView::Template::Text.new("Hello index!")
+ end
+
+ def show
+ render :template => ActionView::Template::Text.new("Hello show!")
+ end
+ end
+
class TestBase < ActiveSupport::TestCase
test "when no layout is specified, and no default is available, render without a layout" do
controller = Blank.new
@@ -260,6 +284,30 @@ module AbstractControllerTests
end
end
end
+
+ test "when specify an :only option which match current action name" do
+ controller = WithOnlyConditional.new
+ controller.process(:show)
+ assert_equal "Overwrite Hello show!", controller.response_body
+ end
+
+ test "when specify an :only option which does not match current action name" do
+ controller = WithOnlyConditional.new
+ controller.process(:index)
+ assert_equal "With Implied Hello index!", controller.response_body
+ end
+
+ test "when specify an :except option which match current action name" do
+ controller = WithExceptConditional.new
+ controller.process(:show)
+ assert_equal "With Implied Hello show!", controller.response_body
+ end
+
+ test "when specify an :except option which does not match current action name" do
+ controller = WithExceptConditional.new
+ controller.process(:index)
+ assert_equal "Overwrite Hello index!", controller.response_body
+ end
end
end
-end \ No newline at end of file
+end