aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorLuke Gruber <luke.gru@gmail.com>2012-03-15 16:40:23 -0400
committerLuke Gruber <luke.gru@gmail.com>2012-03-15 16:40:23 -0400
commitaca693776047f6582109290c4834a3caccfadcc3 (patch)
tree3a67b13d7c27eb88a1ac6df8a9f07f92c8b41ca7 /actionpack/test
parente6c95fe3915bdc1eb1fffd5e508003f0d5f5ad78 (diff)
downloadrails-aca693776047f6582109290c4834a3caccfadcc3.tar.gz
rails-aca693776047f6582109290c4834a3caccfadcc3.tar.bz2
rails-aca693776047f6582109290c4834a3caccfadcc3.zip
allow zero-arity proc for AbstrController::layout
proc without parameters can now be given to AbstractController::layout
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract/layouts_test.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb
index e07a6de4a9..58795aa327 100644
--- a/actionpack/test/abstract/layouts_test.rb
+++ b/actionpack/test/abstract/layouts_test.rb
@@ -72,6 +72,27 @@ module AbstractControllerTests
end
end
+ class WithZeroArityProc < Base
+ layout proc { "overwrite" }
+
+ def index
+ render :template => ActionView::Template::Text.new("Hello zero arity proc!")
+ end
+ end
+
+ class WithProcInContextOfInstance < Base
+ def an_instance_method; end
+
+ layout proc {
+ break unless respond_to? :an_instance_method
+ "overwrite"
+ }
+
+ def index
+ render :template => ActionView::Template::Text.new("Hello again zero arity proc!")
+ end
+ end
+
class WithSymbol < Base
layout :hello
@@ -221,6 +242,18 @@ module AbstractControllerTests
assert_equal "Overwrite Hello proc!", 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)
+ assert_equal "Overwrite Hello zero arity proc!", controller.response_body
+ end
+
+ test "when layout is specified as a proc without parameters the block is evaluated in the context of an instance" do
+ controller = WithProcInContextOfInstance.new
+ controller.process(:index)
+ assert_equal "Overwrite Hello again zero arity proc!", controller.response_body
+ end
+
test "when layout is specified as a symbol, call the requested method and use the layout returned" do
controller = WithSymbol.new
controller.process(:index)