aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-12-18 18:46:14 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2015-12-18 18:46:14 -0800
commit914a45b5fef39c436322bca02566d0d11e1cbb84 (patch)
tree47b4989d09029dc0610a6ec878e928c786ce8911 /activerecord/test/cases
parenta81f73a506a44b39420b9007f4ca3c017c1e74f8 (diff)
parent842f5c2dad8ed021274c16f2dc231c15ddefba18 (diff)
downloadrails-914a45b5fef39c436322bca02566d0d11e1cbb84.tar.gz
rails-914a45b5fef39c436322bca02566d0d11e1cbb84.tar.bz2
rails-914a45b5fef39c436322bca02566d0d11e1cbb84.zip
Merge pull request #19423 from yuroyoro/fix_performance_regression_of_preloading_has_many_through_relation
Fix #12537 performance regression when preloading has_many_through association
Diffstat (limited to 'activerecord/test/cases')
-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 0c09713971..874d53c51f 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -1402,4 +1402,10 @@ class EagerAssociationTest < ActiveRecord::TestCase
post = Post.eager_load(:tags).where('tags.name = ?', 'General').first
assert_equal posts(:welcome), post
end
+
+ # CollectionProxy#reader is expensive, so the preloader avoids calling it.
+ test "preloading has_many_through association avoids calling association.reader" do
+ ActiveRecord::Associations::HasManyAssociation.any_instance.expects(:reader).never
+ Author.preload(:readonly_comments).first!
+ end
end