diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-10-16 00:20:47 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-10-16 00:20:47 +0900 |
commit | 300c68e9396364db063e26473448803c6853e234 (patch) | |
tree | 9a50b96605bc7bdec14b43b5e88ed319a4c3de55 /activerecord/test | |
parent | 8877492df2853cba92d95dabdfcdee7244e7d8f0 (diff) | |
download | rails-300c68e9396364db063e26473448803c6853e234.tar.gz rails-300c68e9396364db063e26473448803c6853e234.tar.bz2 rails-300c68e9396364db063e26473448803c6853e234.zip |
Add a test case that eager-loading with a polymorphic association and using `exists?`
This test covers the case of 02da8aea.
Previously `exists?` was always eager-loading the includes values. But
now it is eager-loaded only when necessary since 07a611e0.
So the case of the eager-loading had not covered in the test.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 559f0e9338..9afe6a893c 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -1501,6 +1501,10 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_equal posts(:welcome), post end + test "eager-loading with a polymorphic association and using the existential predicate" do + assert_equal true, authors(:david).essays.eager_load(:writer).exists? + 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 |