diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-12-18 18:46:14 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-12-18 18:46:14 -0800 |
commit | 914a45b5fef39c436322bca02566d0d11e1cbb84 (patch) | |
tree | 47b4989d09029dc0610a6ec878e928c786ce8911 /activerecord/test | |
parent | a81f73a506a44b39420b9007f4ca3c017c1e74f8 (diff) | |
parent | 842f5c2dad8ed021274c16f2dc231c15ddefba18 (diff) | |
download | rails-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')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 6 |
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 |