aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-10-16 00:20:47 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-10-16 00:20:47 +0900
commit300c68e9396364db063e26473448803c6853e234 (patch)
tree9a50b96605bc7bdec14b43b5e88ed319a4c3de55 /activerecord
parent8877492df2853cba92d95dabdfcdee7244e7d8f0 (diff)
downloadrails-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')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb4
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