Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a test for MissingTemplate change, and changed to use Array.wra…
…p() as

requested by josevalim.
  • Loading branch information
Burke Libbey committed May 6, 2011
1 parent 30d49d0 commit 156039c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/path_set.rb
Expand Up @@ -15,7 +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 = Array.wrap(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)
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/template/error.rb
Expand Up @@ -29,7 +29,7 @@ class MissingTemplate < ActionViewError #:nodoc:


def initialize(paths, path, prefixes, partial, details, *) def initialize(paths, path, prefixes, partial, details, *)
@path = path @path = path
prefixes = [prefixes] if String === prefixes prefixes = Array.wrap(prefixes) if String === prefixes
display_paths = paths.compact.map{ |p| p.to_s.inspect }.join(", ") display_paths = paths.compact.map{ |p| p.to_s.inspect }.join(", ")
template_type = if partial template_type = if partial
"partial" "partial"
Expand Down
9 changes: 9 additions & 0 deletions actionpack/test/template/lookup_context_test.rb
Expand Up @@ -251,4 +251,13 @@ def setup
end end
assert_match %r{Missing partial parent/foo, child/foo with .* Searched in:\n \* "/Path/to/views"\n}, e.message assert_match %r{Missing partial parent/foo, child/foo with .* Searched in:\n \* "/Path/to/views"\n}, e.message
end end

test "if a single prefix is passed as a string and the lookup fails, MissingTemplate accepts it" do
e = assert_raise ActionView::MissingTemplate do
details = {:handlers=>[], :formats=>[], :locale=>[]}
@lookup_context.view_paths.find("foo", "parent", true, details)
end
assert_match %r{Missing partial parent/foo with .* Searched in:\n \* "/Path/to/views"\n}, e.message
end

end end

0 comments on commit 156039c

Please sign in to comment.