aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBurke Libbey <burke@burkelibbey.org>2011-05-06 14:02:31 -0500
committerBurke Libbey <burke@burkelibbey.org>2011-05-06 14:02:31 -0500
commit156039c4cf7f0e0ad697443b121b46d3fe57d801 (patch)
tree6197ccd5d9d98abe65f0719817180617d962856e
parent30d49d001e9060d1898722dfa43b61b7daf90cd4 (diff)
downloadrails-156039c4cf7f0e0ad697443b121b46d3fe57d801.tar.gz
rails-156039c4cf7f0e0ad697443b121b46d3fe57d801.tar.bz2
rails-156039c4cf7f0e0ad697443b121b46d3fe57d801.zip
Added a test for MissingTemplate change, and changed to use Array.wrap() as
requested by josevalim.
-rw-r--r--actionpack/lib/action_view/path_set.rb2
-rw-r--r--actionpack/lib/action_view/template/error.rb2
-rw-r--r--actionpack/test/template/lookup_context_test.rb9
3 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/path_set.rb b/actionpack/lib/action_view/path_set.rb
index 8b840a6463..1e38b82852 100644
--- a/actionpack/lib/action_view/path_set.rb
+++ b/actionpack/lib/action_view/path_set.rb
@@ -15,7 +15,7 @@ module ActionView #:nodoc:
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)
diff --git a/actionpack/lib/action_view/template/error.rb b/actionpack/lib/action_view/template/error.rb
index fa7a620daa..6eec0cc23d 100644
--- a/actionpack/lib/action_view/template/error.rb
+++ b/actionpack/lib/action_view/template/error.rb
@@ -29,7 +29,7 @@ module ActionView
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"
diff --git a/actionpack/test/template/lookup_context_test.rb b/actionpack/test/template/lookup_context_test.rb
index 5fb1fdc044..94af97ee11 100644
--- a/actionpack/test/template/lookup_context_test.rb
+++ b/actionpack/test/template/lookup_context_test.rb
@@ -251,4 +251,13 @@ class TestMissingTemplate < ActiveSupport::TestCase
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