mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ensure that the tests use the instance-level view-paths correctly. Closes #10820 [lifofifo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8645 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
76ea495ec9
commit
8a71f87009
2 changed files with 16 additions and 11 deletions
|
@ -642,11 +642,11 @@ module ActionController #:nodoc:
|
||||||
|
|
||||||
# View load paths for controller.
|
# View load paths for controller.
|
||||||
def view_paths
|
def view_paths
|
||||||
(@template || self.class).view_paths
|
@template.view_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
def view_paths=(value)
|
def view_paths=(value)
|
||||||
(@template || self.class).view_paths = value
|
@template.view_paths = value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a view_path to the front of the view_paths array.
|
# Adds a view_path to the front of the view_paths array.
|
||||||
|
@ -656,7 +656,7 @@ module ActionController #:nodoc:
|
||||||
# self.prepend_view_path(["views/default", "views/custom"])
|
# self.prepend_view_path(["views/default", "views/custom"])
|
||||||
#
|
#
|
||||||
def prepend_view_path(path)
|
def prepend_view_path(path)
|
||||||
(@template || self.class).prepend_view_path(path)
|
@template.prepend_view_path(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a view_path to the end of the view_paths array.
|
# Adds a view_path to the end of the view_paths array.
|
||||||
|
@ -666,7 +666,7 @@ module ActionController #:nodoc:
|
||||||
# self.append_view_path(["views/default", "views/custom"])
|
# self.append_view_path(["views/default", "views/custom"])
|
||||||
#
|
#
|
||||||
def append_view_path(path)
|
def append_view_path(path)
|
||||||
(@template || self.class).append_view_path(path)
|
@template.append_view_path(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -1119,7 +1119,7 @@ module ActionController #:nodoc:
|
||||||
raise "You must assign a template class through ActionController.template_class= before processing a request"
|
raise "You must assign a template class through ActionController.template_class= before processing a request"
|
||||||
end
|
end
|
||||||
|
|
||||||
response.template = ActionView::Base.new(view_paths, {}, self)
|
response.template = ActionView::Base.new(self.class.view_paths, {}, self)
|
||||||
response.template.extend self.class.master_helper_module
|
response.template.extend self.class.master_helper_module
|
||||||
response.redirected_to = nil
|
response.redirected_to = nil
|
||||||
@performed_render = @performed_redirect = false
|
@performed_render = @performed_redirect = false
|
||||||
|
|
|
@ -28,10 +28,15 @@ class ViewLoadPathsTest < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
TestController.view_paths = nil
|
TestController.view_paths = nil
|
||||||
ActionView::Base.cache_template_extensions = false
|
ActionView::Base.cache_template_extensions = false
|
||||||
@controller = TestController.new
|
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
@response = ActionController::TestResponse.new
|
@response = ActionController::TestResponse.new
|
||||||
|
|
||||||
|
@controller = TestController.new
|
||||||
|
# Following is needed in order to setup @controller.template object properly
|
||||||
|
@controller.send :initialize_template_class, @response
|
||||||
|
@controller.send :assign_shortcuts, @request, @response
|
||||||
|
|
||||||
# Track the last warning.
|
# Track the last warning.
|
||||||
@old_behavior = ActiveSupport::Deprecation.behavior
|
@old_behavior = ActiveSupport::Deprecation.behavior
|
||||||
@last_message = nil
|
@last_message = nil
|
||||||
|
@ -48,18 +53,18 @@ class ViewLoadPathsTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_controller_appends_view_path_correctly
|
def test_controller_appends_view_path_correctly
|
||||||
TestController.append_view_path 'foo'
|
@controller.append_view_path 'foo'
|
||||||
assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths
|
assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths
|
||||||
|
|
||||||
TestController.append_view_path(%w(bar baz))
|
@controller.append_view_path(%w(bar baz))
|
||||||
assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
|
assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_controller_prepends_view_path_correctly
|
def test_controller_prepends_view_path_correctly
|
||||||
TestController.prepend_view_path 'baz'
|
@controller.prepend_view_path 'baz'
|
||||||
assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths
|
assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths
|
||||||
|
|
||||||
TestController.prepend_view_path(%w(foo bar))
|
@controller.prepend_view_path(%w(foo bar))
|
||||||
assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
|
assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue