From 7252666b74e00c569b431d1a798fb7280923929f Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Wed, 17 May 2006 07:25:36 +0000 Subject: Add layout attribute to response object with the name of the layout that was rendered, or nil if none rendered. [Kevin Clark kevin.clark@gmail.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4346 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/layout_test.rb | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index c7db19ccc9..9dc0cdcfe9 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -70,4 +70,55 @@ class LayoutAutoDiscoveryTest < Test::Unit::TestCase assert_equal 'layouts/controller_name_space/nested', @controller.active_layout assert_equal 'controller_name_space/nested.rhtml hello.rhtml', @response.body end +end + + +class DefaultLayoutController < LayoutTest +end + +class HasOwnLayoutController < LayoutTest + layout 'item' +end + +class SetsLayoutInRenderController < LayoutTest + def hello + render :layout => 'third_party_template_library' + end +end + +class RendersNoLayoutController < LayoutTest + def hello + render :layout => false + end +end + +class LayoutSetInResponseTest < Test::Unit::TestCase + def setup + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_layout_set_when_using_default_layout + @controller = DefaultLayoutController.new + get :hello + assert_equal 'layouts/layout_test', @response.layout + end + + def test_layout_set_when_set_in_controller + @controller = HasOwnLayoutController.new + get :hello + assert_equal 'layouts/item', @response.layout + end + + def test_layout_set_when_using_render + @controller = SetsLayoutInRenderController.new + get :hello + assert_equal 'layouts/third_party_template_library', @response.layout + end + + def test_layout_is_not_set_when_none_rendered + @controller = RendersNoLayoutController.new + get :hello + assert_nil @response.layout + end end \ No newline at end of file -- cgit v1.2.3