1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Ryuta Kamizono 2017-10-16 00:20:47 +09:00
parent 8877492df2
commit 300c68e939

View file

@ -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