提交 a26d407f 编写于 作者: D David Chelimsky 提交者: José Valim

ActionView::PathSet# accepts String or Array

- Closes #6692
Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 bd3b2241
...@@ -15,6 +15,7 @@ def find(*args) ...@@ -15,6 +15,7 @@ def find(*args)
end end
def find_all(path, prefixes = [], *args) def find_all(path, prefixes = [], *args)
prefixes = [prefixes] if String === prefixes
prefixes.each do |prefix| prefixes.each do |prefix|
each do |resolver| each do |resolver|
templates = resolver.find_all(path, prefix, *args) templates = resolver.find_all(path, prefix, *args)
......
...@@ -131,6 +131,35 @@ def test_view_paths_override_at_request_time ...@@ -131,6 +131,35 @@ def test_view_paths_override_at_request_time
assert_equal "Hello overridden world!", @response.body assert_equal "Hello overridden world!", @response.body
end 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 def test_inheritance
original_load_paths = ActionController::Base.view_paths original_load_paths = ActionController::Base.view_paths
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册