aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-02-11 21:24:11 +0100
committerYves Senn <yves.senn@gmail.com>2013-02-19 11:11:27 +0100
commit587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b (patch)
treef73e5e490d1e5de640f83797a2b19325e2f82fb5 /activerecord/test
parent46b65ba274bea6f8d52926e4b243db28d6377fc0 (diff)
downloadrails-587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b.tar.gz
rails-587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b.tar.bz2
rails-587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b.zip
don't cache invalid subsets when preloading hmt associations.
Backport #9252. Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/associations/eager_test.rb The preloader code on 3-2-stable is not based on relations but on option hashes. I had to modify the original patch and comparing the option hashes could be more fuzzy than comparing the relations. All the tests passed though.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 20c6b691fc..5d07ffa241 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -1112,4 +1112,10 @@ class EagerAssociationTest < ActiveRecord::TestCase
Post.includes(:comments).order(nil).where(:comments => {:body => "Thank you for the welcome"}).first
end
end
+
+ test "preloading does not cache has many association subset when preloaded with a through association" do
+ author = Author.includes(:comments_with_order_and_conditions, :posts).first
+ assert_no_queries { assert_equal 2, author.comments_with_order_and_conditions.size }
+ assert_no_queries { assert_equal 5, author.posts.size, "should not cache a subset of the association" }
+ end
end