aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-10-14 16:39:57 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-10-14 16:39:57 -0700
commit2eee8af4d058b60323b60dd1a56c247e485c0835 (patch)
treebeb6bc9e3a88cfc5117095184943a874d37957ef /activerecord/test/cases
parentb59d47d82e6ecb4308b675875b5a62c79858645e (diff)
downloadrails-2eee8af4d058b60323b60dd1a56c247e485c0835.tar.gz
rails-2eee8af4d058b60323b60dd1a56c247e485c0835.tar.bz2
rails-2eee8af4d058b60323b60dd1a56c247e485c0835.zip
make sure cache is not used for collection assocations too
follow up for #17052
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/scoping/relation_scoping_test.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/test/cases/scoping/relation_scoping_test.rb b/activerecord/test/cases/scoping/relation_scoping_test.rb
index c63fea15f2..29b32576b8 100644
--- a/activerecord/test/cases/scoping/relation_scoping_test.rb
+++ b/activerecord/test/cases/scoping/relation_scoping_test.rb
@@ -7,6 +7,7 @@ require 'models/comment'
require 'models/category'
require 'models/person'
require 'models/reference'
+require 'models/reference'
class RelationScopingTest < ActiveRecord::TestCase
fixtures :authors, :developers, :projects, :comments, :posts, :developers_projects
@@ -19,12 +20,22 @@ class RelationScopingTest < ActiveRecord::TestCase
author = authors :mary
assert_nil author.first_post
post = FirstPost.unscoped do
- author = authors :mary
author.reload.first_post
end
assert post
end
+ def test_scope_breaks_caching_on_collections
+ author = authors :david
+ ids = author.reload.special_posts_with_default_scope.map(&:id)
+ assert_equal [1,5,6], ids.sort
+ scoped_posts = SpecialPostWithDefaultScope.unscoped do
+ author = authors :david
+ author.reload.special_posts_with_default_scope.to_a
+ end
+ assert_equal author.posts.map(&:id).sort, scoped_posts.map(&:id).sort
+ end
+
def test_reverse_order
assert_equal Developer.order("id DESC").to_a.reverse, Developer.order("id DESC").reverse_order
end