aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2012-10-08 22:22:47 +0200
committerYves Senn <yves.senn@garaio.com>2012-10-11 08:46:49 +0200
commited9567401dfc7b476bf9ccac82826fc63283f708 (patch)
tree4e9da4c25d623281aff8438a65934cd3526834a3 /actionpack/lib
parentcd98c25ebedc27fe892468bb87ea260fb070f5eb (diff)
downloadrails-ed9567401dfc7b476bf9ccac82826fc63283f708.tar.gz
rails-ed9567401dfc7b476bf9ccac82826fc63283f708.tar.bz2
rails-ed9567401dfc7b476bf9ccac82826fc63283f708.zip
recognizes when a partial was rendered twice. Closes #3675
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/test_case.rb14
-rw-r--r--actionpack/lib/action_view/test_case.rb13
2 files changed, 18 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index ace5a2c822..6aa43edf47 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -123,11 +123,17 @@ module ActionController
if expected_partial = options[:partial]
if expected_locals = options[:locals]
- if defined?(@locals)
- actual_locals = @locals[expected_partial.to_s.sub(/^_/,'')]
- expected_locals.each_pair do |k,v|
- assert_equal(v, actual_locals[k])
+ if defined?(@_locals)
+ actual_locals_collection = @_locals[expected_partial.to_s.sub(/^_/,'')]
+ result = actual_locals_collection.any? do |actual_locals|
+ expected_locals.each_pair.all? do |k,v|
+ v == actual_locals[k]
+ end
end
+ msg = 'expecting %s to be rendered with %s but was with %s' % [expected_partial,
+ expected_locals,
+ actual_locals_collection]
+ assert(result, msg)
else
warn "the :locals option to #assert_template is only supported in a ActionView::TestCase"
end
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 5434b3421e..6e5a3a63ca 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -120,7 +120,7 @@ module ActionView
end
def locals
- @locals ||= {}
+ @_locals ||= {}
end
included do
@@ -162,12 +162,15 @@ module ActionView
case options
when Hash
if block_given?
- locals[options[:layout]] = options[:locals]
+ locals[options[:layout]] ||= []
+ locals[options[:layout]] << options[:locals]
elsif options.key?(:partial)
- locals[options[:partial]] = options[:locals]
+ locals[options[:partial]] ||= []
+ locals[options[:partial]] << options[:locals]
end
else
- locals[options] = local_assigns
+ locals[options] ||= []
+ locals[options] << local_assigns
end
super
@@ -197,7 +200,7 @@ module ActionView
:@_routes,
:@controller,
:@_layouts,
- :@locals,
+ :@_locals,
:@method_name,
:@output_buffer,
:@_partials,