From 68a207ccf6dffa58c9a9a3e221b99af72859ce27 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Thu, 21 May 2009 18:14:20 -0700 Subject: Implemented layout conditions in new base --- actionpack/test/controller/layout_test.rb | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index 5b7d40d16d..1cd448d5e8 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -9,8 +9,11 @@ ActionView::Template::register_template_handler :mab, ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../fixtures/layout_tests/' ] +require "lib/fixture_template" + class LayoutTest < ActionController::Base def self.controller_path; 'views' end + def self._implied_layout_name; to_s.underscore.gsub(/_controller$/, '') ; end self.view_paths = ActionController::Base.view_paths.dup end @@ -35,6 +38,15 @@ end class MultipleExtensions < LayoutTest end +if defined?(ActionController::Http) + LayoutTest._write_layout_method + ProductController._write_layout_method + ItemController._write_layout_method + ThirdPartyTemplateLibraryController._write_layout_method + MultipleExtensions._write_layout_method + ControllerNameSpace::NestedController._write_layout_method +end + class LayoutAutoDiscoveryTest < ActionController::TestCase def setup super @@ -56,23 +68,19 @@ class LayoutAutoDiscoveryTest < ActionController::TestCase def test_third_party_template_library_auto_discovers_layout @controller = ThirdPartyTemplateLibraryController.new get :hello - assert @controller.active_layout(true).identifier.include?('layouts/third_party_template_library.mab') - assert @controller.template.layout.include?('layouts/third_party_template_library') assert_response :success - assert_equal 'Mab', @response.body + assert_equal 'layouts/third_party_template_library.mab', @response.body end - def test_namespaced_controllers_auto_detect_layouts + def test_namespaced_controllers_auto_detect_layouts1 @controller = ControllerNameSpace::NestedController.new get :hello - assert_equal 'layouts/controller_name_space/nested', @controller.active_layout(true).to_s assert_equal 'controller_name_space/nested.rhtml hello.rhtml', @response.body end - def test_namespaced_controllers_auto_detect_layouts + def test_namespaced_controllers_auto_detect_layouts2 @controller = MultipleExtensions.new get :hello - assert @controller.active_layout(true).identifier.include?('layouts/multiple_extensions.html.erb') assert_equal 'multiple_extensions.html.erb hello.rhtml', @response.body.strip end end @@ -139,7 +147,7 @@ class LayoutSetInResponseTest < ActionController::TestCase def test_layout_only_exception_when_excepted @controller = OnlyLayoutController.new get :goodbye - assert_equal nil, @controller.template.layout + assert !@response.body.include?("item.rhtml"), "#{@response.body.inspect} included 'item.rhtml'" end def test_layout_except_exception_when_included @@ -151,7 +159,7 @@ class LayoutSetInResponseTest < ActionController::TestCase def test_layout_except_exception_when_excepted @controller = ExceptLayoutController.new get :goodbye - assert_equal nil, @controller.template.layout + assert !@response.body.include?("item.rhtml"), "#{@response.body.inspect} included 'item.rhtml'" end def test_layout_set_when_using_render -- cgit v1.2.3