Permalink
Browse files

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
  • Loading branch information...
senny committed Mar 22, 2013
1 parent a1d0b8c commit 22a819a2c24e03e45ded344629e9bcf730d020c3
Showing with 7 additions and 0 deletions.
  1. +7 −0 activerecord/test/cases/associations/eager_test.rb
@@ -1174,6 +1174,13 @@ def test_deep_including_through_habtm
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

0 comments on commit 22a819a

Please sign in to comment.