diff options
Diffstat (limited to 'actionpack/test/controller/layout_test.rb')
-rw-r--r-- | actionpack/test/controller/layout_test.rb | 51 |
1 files changed, 51 insertions, 0 deletions
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 |