aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/actionpack/controller/layout_test.rb
diff options
context:
space:
mode:
authorZuhao Wan <wanzuhao@gmail.com>2014-06-09 22:45:46 +0800
committerZuhao Wan <wanzuhao@gmail.com>2014-06-12 18:49:40 +0800
commita1dbb4e7e0a580e013423c7adf8ba3127c4c59e0 (patch)
tree1a6065836115a0592c89fd09dd6363a49466aa91 /actionview/test/actionpack/controller/layout_test.rb
parenta5c12cbd3c0e9b392edb9e4eb13dcdd256327acd (diff)
downloadrails-a1dbb4e7e0a580e013423c7adf8ba3127c4c59e0.tar.gz
rails-a1dbb4e7e0a580e013423c7adf8ba3127c4c59e0.tar.bz2
rails-a1dbb4e7e0a580e013423c7adf8ba3127c4c59e0.zip
Add unregister_template_handler to prevent leaks.
Diffstat (limited to 'actionview/test/actionpack/controller/layout_test.rb')
-rw-r--r--actionview/test/actionpack/controller/layout_test.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/actionview/test/actionpack/controller/layout_test.rb b/actionview/test/actionpack/controller/layout_test.rb
index b44f57a23e..70d81c0cad 100644
--- a/actionview/test/actionpack/controller/layout_test.rb
+++ b/actionview/test/actionpack/controller/layout_test.rb
@@ -1,14 +1,12 @@
require 'abstract_unit'
require 'rbconfig'
require 'active_support/core_ext/array/extract_options'
+require 'support/template_handler_helper'
# The view_paths array must be set on Base and not LayoutTest so that LayoutTest's inherited
# method has access to the view_paths array when looking for a layout to automatically assign.
old_load_paths = ActionController::Base.view_paths
-ActionView::Template::register_template_handler :mab,
- lambda { |template| template.source.inspect }
-
ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../../fixtures/actionpack/layout_tests/' ]
class LayoutTest < ActionController::Base
@@ -39,6 +37,8 @@ class MultipleExtensions < LayoutTest
end
class LayoutAutoDiscoveryTest < ActionController::TestCase
+ include TemplateHandlerHelper
+
def setup
super
@request.host = "www.nextangle.com"
@@ -57,10 +57,12 @@ class LayoutAutoDiscoveryTest < ActionController::TestCase
end
def test_third_party_template_library_auto_discovers_layout
- @controller = ThirdPartyTemplateLibraryController.new
- get :hello
- assert_response :success
- assert_equal 'layouts/third_party_template_library.mab', @response.body
+ with_template_handler :mab, lambda { |template| template.source.inspect } do
+ @controller = ThirdPartyTemplateLibraryController.new
+ get :hello
+ assert_response :success
+ assert_equal 'layouts/third_party_template_library.mab', @response.body
+ end
end
def test_namespaced_controllers_auto_detect_layouts1
@@ -135,6 +137,7 @@ end
class LayoutSetInResponseTest < ActionController::TestCase
include ActionView::Template::Handlers
+ include TemplateHandlerHelper
def test_layout_set_when_using_default_layout
@controller = DefaultLayoutController.new
@@ -191,9 +194,11 @@ class LayoutSetInResponseTest < ActionController::TestCase
end
def test_layout_set_when_using_render
- @controller = SetsLayoutInRenderController.new
- get :hello
- assert_template :layout => "layouts/third_party_template_library"
+ with_template_handler :mab, lambda { |template| template.source.inspect } do
+ @controller = SetsLayoutInRenderController.new
+ get :hello
+ assert_template :layout => "layouts/third_party_template_library"
+ end
end
def test_layout_is_not_set_when_none_rendered