diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-03-22 15:18:18 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-03-22 15:18:18 +0100 |
commit | 22a819a2c24e03e45ded344629e9bcf730d020c3 (patch) | |
tree | 52c3b0523cee69e5b9149dd3ef5a0842a6fdb6d7 /activerecord | |
parent | a1d0b8c67b514d2d339d8687f64de7a84b4700e5 (diff) | |
download | rails-22a819a2c24e03e45ded344629e9bcf730d020c3.tar.gz rails-22a819a2c24e03e45ded344629e9bcf730d020c3.tar.bz2 rails-22a819a2c24e03e45ded344629e9bcf730d020c3.zip |
test-case to prevent resetting associations when preloading twice.
Conflicts:
activerecord/lib/active_record/associations/preloader/through_association.rb
activerecord/test/cases/associations/eager_test.rb
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 3a5dea6f13..d6850215b5 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -1174,6 +1174,13 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_no_queries { assert_equal 5, author.posts.size, "should not cache a subset of the association" } end + test "preloading a through association twice does not reset it" do + members = Member.includes(current_membership: :club).includes(:club).to_a + assert_no_queries { + assert_equal 3, members.map(&:current_membership).map(&:club).size + } + end + test "works in combination with order(:symbol)" do author = Author.includes(:posts).references(:posts).order(:name).where('posts.title IS NOT NULL').first assert_equal authors(:bob), author |