aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/eager_test.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2013-03-22 07:24:51 -0700
committerJon Leighton <j@jonathanleighton.com>2013-03-22 07:24:51 -0700
commitd8d6dada77d7d30526b0f8d11928ec94e9f79db9 (patch)
tree52c3b0523cee69e5b9149dd3ef5a0842a6fdb6d7 /activerecord/test/cases/associations/eager_test.rb
parenta1d0b8c67b514d2d339d8687f64de7a84b4700e5 (diff)
parent22a819a2c24e03e45ded344629e9bcf730d020c3 (diff)
downloadrails-d8d6dada77d7d30526b0f8d11928ec94e9f79db9.tar.gz
rails-d8d6dada77d7d30526b0f8d11928ec94e9f79db9.tar.bz2
rails-d8d6dada77d7d30526b0f8d11928ec94e9f79db9.zip
Merge pull request #9872 from senny/test_case_to_prevent_unnecessary_reset
test-case to prevent resetting associations when preloading twice.
Diffstat (limited to 'activerecord/test/cases/associations/eager_test.rb')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb7
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