Permalink
Browse files

Added a test for MissingTemplate change, and changed to use Array.wra…

…p() as

requested by josevalim.
  • Loading branch information...
1 parent 30d49d0 commit 156039c4cf7f0e0ad697443b121b46d3fe57d801 Burke Libbey committed May 6, 2011
@@ -15,7 +15,7 @@ def find(*args)
end
def find_all(path, prefixes = [], *args)
- prefixes = [prefixes] if String === prefixes
+ prefixes = Array.wrap(prefixes) if String === prefixes
prefixes.each do |prefix|
each do |resolver|
templates = resolver.find_all(path, prefix, *args)
@@ -29,7 +29,7 @@ class MissingTemplate < ActionViewError #:nodoc:
def initialize(paths, path, prefixes, partial, details, *)
@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(", ")
template_type = if partial
"partial"
@@ -251,4 +251,13 @@ def setup
end
assert_match %r{Missing partial parent/foo, child/foo with .* Searched in:\n \* "/Path/to/views"\n}, e.message
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

0 comments on commit 156039c

Please sign in to comment.