Permalink
Browse files

Merge pull request #9872 from senny/test_case_to_prevent_unnecessary_…

…reset

test-case to prevent resetting associations when preloading twice.
  • Loading branch information...
jonleighton committed Mar 22, 2013
2 parents a1d0b8c + 22a819a commit d8d6dada77d7d30526b0f8d11928ec94e9f79db9
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 d8d6dad

Please sign in to comment.