aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-04-07 01:16:45 +0100
committerPratik Naik <pratiknaik@gmail.com>2010-04-07 01:16:45 +0100
commit48634bf59a0ed89cddd4a539c08866c9e025c5e3 (patch)
treeac4526ffd409f5b24f2671b5579908ab12d006dc /activerecord/test
parenteb063538bd58c915c953e4b8a295d3a1b1a321d5 (diff)
downloadrails-48634bf59a0ed89cddd4a539c08866c9e025c5e3.tar.gz
rails-48634bf59a0ed89cddd4a539c08866c9e025c5e3.tar.bz2
rails-48634bf59a0ed89cddd4a539c08866c9e025c5e3.zip
Reset named scope cache whenever the @target is reset
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/named_scope_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index 3d5ebb6cb8..e4cafad11e 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -422,6 +422,16 @@ class NamedScopeTest < ActiveRecord::TestCase
post.comments.containing_the_letter_e.all # force load
assert_no_queries { post.comments.containing_the_letter_e.all }
end
+
+ def test_named_scopes_are_reset_on_association_reload
+ post = posts(:welcome)
+
+ [:destroy_all, :reset, :delete_all].each do |method|
+ before = post.comments.containing_the_letter_e
+ post.comments.send(method)
+ assert before.object_id != post.comments.containing_the_letter_e.object_id, "AssociationCollection##{method} should reset the named scopes cache"
+ end
+ end
end
class DynamicScopeMatchTest < ActiveRecord::TestCase