aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-05-08 03:35:14 -0700
committerJosé Valim <jose.valim@gmail.com>2011-05-08 03:35:14 -0700
commit843cab6f98e2d6c99bc913bd2aade6c848e4ce8d (patch)
tree3725e7e1a0575c59476c8e35d5b0cbe7fd5aa1a3 /actionpack
parent30db3a82f653e7d7215e41bec525932cf5b17de1 (diff)
parent06671c37de93702323ee281aedc4023bb8d7cdb6 (diff)
downloadrails-843cab6f98e2d6c99bc913bd2aade6c848e4ce8d.tar.gz
rails-843cab6f98e2d6c99bc913bd2aade6c848e4ce8d.tar.bz2
rails-843cab6f98e2d6c99bc913bd2aade6c848e4ce8d.zip
Merge pull request #420 from burke/master
Accept single prefix in ActionView::MissingTemplate#initialize
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/path_set.rb4
-rw-r--r--actionpack/lib/action_view/template/error.rb2
-rw-r--r--actionpack/test/template/lookup_context_test.rb9
3 files changed, 14 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/path_set.rb b/actionpack/lib/action_view/path_set.rb
index 8b840a6463..54b9a6d39e 100644
--- a/actionpack/lib/action_view/path_set.rb
+++ b/actionpack/lib/action_view/path_set.rb
@@ -1,3 +1,5 @@
+require "active_support/core_ext/array/wrap"
+
module ActionView #:nodoc:
# = Action View PathSet
class PathSet < Array #:nodoc:
@@ -15,7 +17,7 @@ module ActionView #:nodoc:
end
def find_all(path, prefixes = [], *args)
- prefixes = [prefixes] if String === prefixes
+ prefixes = Array.wrap(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 e246646963..d4448a7b33 100644
--- a/actionpack/lib/action_view/template/error.rb
+++ b/actionpack/lib/action_view/template/error.rb
@@ -1,3 +1,4 @@
+require "active_support/core_ext/array/wrap"
require "active_support/core_ext/enumerable"
module ActionView
@@ -29,6 +30,7 @@ module ActionView
def initialize(paths, path, prefixes, partial, details, *)
@path = path
+ prefixes = Array.wrap(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 f34a40795a..47b70f05ab 100644
--- a/actionpack/test/template/lookup_context_test.rb
+++ b/actionpack/test/template/lookup_context_test.rb
@@ -256,4 +256,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