mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ActionView::PathSet# accepts String or Array
- Closes #6692 Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
bd3b2241a4
commit
a26d407f63
2 changed files with 30 additions and 0 deletions
|
@ -15,6 +15,7 @@ module ActionView #:nodoc:
|
|||
end
|
||||
|
||||
def find_all(path, prefixes = [], *args)
|
||||
prefixes = [prefixes] if String === prefixes
|
||||
prefixes.each do |prefix|
|
||||
each do |resolver|
|
||||
templates = resolver.find_all(path, prefix, *args)
|
||||
|
|
|
@ -131,6 +131,35 @@ class ViewLoadPathsTest < ActionController::TestCase
|
|||
assert_equal "Hello overridden world!", @response.body
|
||||
end
|
||||
|
||||
def test_override_view_paths_with_custom_resolver
|
||||
resolver_class = Class.new(ActionView::PathResolver) do
|
||||
def initialize(path_set)
|
||||
@path_set = path_set
|
||||
end
|
||||
|
||||
def find_all(*args)
|
||||
@path_set.find_all(*args).collect do |template|
|
||||
::ActionView::Template.new(
|
||||
"Customized body",
|
||||
template.identifier,
|
||||
template.handler,
|
||||
{
|
||||
:virtual_path => template.virtual_path,
|
||||
:format => template.formats
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resolver = resolver_class.new(TestController.view_paths)
|
||||
TestController.view_paths = ActionView::PathSet.new.push(resolver)
|
||||
|
||||
get :hello_world
|
||||
assert_response :success
|
||||
assert_equal "Customized body", @response.body
|
||||
end
|
||||
|
||||
def test_inheritance
|
||||
original_load_paths = ActionController::Base.view_paths
|
||||
|
||||
|
|
Loading…
Reference in a new issue