aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract/layouts_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-10-21 15:55:47 -0200
committerYehuda Katz <wycats@gmail.com>2009-11-01 02:23:48 +0100
commit0cf16ddb88b4fa28c37e576d50d835b100c3f6a1 (patch)
treeebc8dd87cc054d9c544a33e27f484205467a939c /actionpack/test/abstract/layouts_test.rb
parent2d514e5352d17c8c3958b26397f1c808c7fa0b3c (diff)
downloadrails-0cf16ddb88b4fa28c37e576d50d835b100c3f6a1.tar.gz
rails-0cf16ddb88b4fa28c37e576d50d835b100c3f6a1.tar.bz2
rails-0cf16ddb88b4fa28c37e576d50d835b100c3f6a1.zip
Improve AbstractController layouts coverage.
Diffstat (limited to 'actionpack/test/abstract/layouts_test.rb')
-rw-r--r--actionpack/test/abstract/layouts_test.rb53
1 files changed, 41 insertions, 12 deletions
diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb
index 453d31826e..9c29696ad5 100644
--- a/actionpack/test/abstract/layouts_test.rb
+++ b/actionpack/test/abstract/layouts_test.rb
@@ -17,17 +17,6 @@ module AbstractControllerTests
"layouts/omg.erb" => "OMGHI2U <%= yield %>",
"layouts/with_false_layout.erb" => "False Layout <%= yield %>"
)]
-
- def self.controller_path
- @controller_path ||= self.name.sub(/Controller$/, '').underscore
- end
-
- def controller_path() self.class.controller_path end
-
- def render_to_body(options)
- options[:_layout] = _default_layout({})
- super
- end
end
class Blank < Base
@@ -44,6 +33,22 @@ module AbstractControllerTests
def index
render :_template => ActionView::TextTemplate.new("Hello string!")
end
+
+ def overwrite_default
+ render :_template => ActionView::TextTemplate.new("Hello string!"), :layout => :default
+ end
+
+ def overwrite_false
+ render :_template => ActionView::TextTemplate.new("Hello string!"), :layout => false
+ end
+
+ def overwrite_string
+ render :_template => ActionView::TextTemplate.new("Hello string!"), :layout => "omg"
+ end
+
+ def overwrite_skip
+ render :text => "Hello text!"
+ end
end
class WithStringChild < WithString
@@ -153,7 +158,31 @@ module AbstractControllerTests
controller.process(:index)
assert_equal "With String Hello string!", controller.response_body
end
-
+
+ test "when layout is overwriten by :default in render, render default layout" do
+ controller = WithString.new
+ controller.process(:overwrite_default)
+ assert_equal "With String Hello string!", controller.response_body
+ end
+
+ test "when layout is overwriten by string in render, render new layout" do
+ controller = WithString.new
+ controller.process(:overwrite_string)
+ assert_equal "OMGHI2U Hello string!", controller.response_body
+ end
+
+ test "when layout is overwriten by false in render, render no layout" do
+ controller = WithString.new
+ controller.process(:overwrite_false)
+ assert_equal "Hello string!", controller.response_body
+ end
+
+ test "when text is rendered, render no layout" do
+ controller = WithString.new
+ controller.process(:overwrite_skip)
+ assert_equal "Hello text!", controller.response_body
+ end
+
test "when layout is specified as a string, but the layout is missing, raise an exception" do
assert_raises(ActionView::MissingTemplate) { WithMissingLayout.new.process(:index) }
end