aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/layout_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/layout_test.rb')
-rw-r--r--actionpack/test/controller/layout_test.rb43
1 files changed, 27 insertions, 16 deletions
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index 5b7d40d16d..cb9bdf57bb 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 "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
@@ -166,15 +174,18 @@ class LayoutSetInResponseTest < ActionController::TestCase
assert_nil @controller.template.layout
end
- def test_exempt_from_layout_honored_by_render_template
- ActionController::Base.exempt_from_layout :erb
- @controller = RenderWithTemplateOptionController.new
+ for_tag(:old_base) do
+ # exempt_from_layout is deprecated
+ def test_exempt_from_layout_honored_by_render_template
+ ActionController::Base.exempt_from_layout :erb
+ @controller = RenderWithTemplateOptionController.new
- get :hello
- assert_equal "alt/hello.rhtml", @response.body.strip
+ get :hello
+ assert_equal "alt/hello.rhtml", @response.body.strip
- ensure
- ActionController::Base.exempt_from_layout.delete(ERB)
+ ensure
+ ActionController::Base.exempt_from_layout.delete(ERB)
+ end
end
def test_layout_is_picked_from_the_controller_instances_view_path