diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-04-07 01:16:45 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-04-07 01:16:45 +0100 |
commit | 48634bf59a0ed89cddd4a539c08866c9e025c5e3 (patch) | |
tree | ac4526ffd409f5b24f2671b5579908ab12d006dc /activerecord/test | |
parent | eb063538bd58c915c953e4b8a295d3a1b1a321d5 (diff) | |
download | rails-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.rb | 10 |
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 |