diff options
author | Marcel Molina <marcel@vernix.org> | 2006-05-17 07:25:36 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2006-05-17 07:25:36 +0000 |
commit | 7252666b74e00c569b431d1a798fb7280923929f (patch) | |
tree | 2f6ba0b6fbf8cfcccfac4ae4496b15484068fb03 /actionpack/test | |
parent | 36d1a2f302817815e0e70334733d2daf1a14a4f5 (diff) | |
download | rails-7252666b74e00c569b431d1a798fb7280923929f.tar.gz rails-7252666b74e00c569b431d1a798fb7280923929f.tar.bz2 rails-7252666b74e00c569b431d1a798fb7280923929f.zip |
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
Diffstat (limited to 'actionpack/test')
-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 |