diff --git a/actionpack/lib/action_view/path_set.rb b/actionpack/lib/action_view/path_set.rb index e3de3e1eac6c4875cca64c90e690d46404b1993c..8b840a6463a3847dff6cd64902be5d468c3d618d 100644 --- a/actionpack/lib/action_view/path_set.rb +++ b/actionpack/lib/action_view/path_set.rb @@ -15,6 +15,7 @@ def find(*args) 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) diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb index edfcb5cc4d7c7752d1a998fe1548f8f1d80e2496..9280a1c2d3e9b3df430e436794665f3c9631821e 100644 --- a/actionpack/test/controller/view_paths_test.rb +++ b/actionpack/test/controller/view_paths_test.rb @@ -131,6 +131,35 @@ def test_view_paths_override_at_request_time 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