diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-03-02 06:49:33 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-03-04 02:36:15 +0900 |
commit | 7d5a7b30cc79d91f3e3fa8ee81a077276947eb72 (patch) | |
tree | d9f7cd6a0813daa24c6636092462e021c8d5c44a /activerecord/test | |
parent | d35875b7a3f559155a9378cbe9203b0b8ea580f9 (diff) | |
download | rails-7d5a7b30cc79d91f3e3fa8ee81a077276947eb72.tar.gz rails-7d5a7b30cc79d91f3e3fa8ee81a077276947eb72.tar.bz2 rails-7d5a7b30cc79d91f3e3fa8ee81a077276947eb72.zip |
Eager loading with polymorphic associations should behave consistently
This reverts ignoring polymorphic error introduced at 02da8ae.
What the ignoring want to solve was caused by force eager loading
regardless of whether it is necessary, but it has been fixed by #29043.
The ignoring is now only causing a mismatch of `exists?` behavior with
`to_a`, `count`, etc. It should behave consistently.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index cb07ca5cd3..f18c6177ac 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -1501,8 +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? + test "eager-loading with a polymorphic association won't work consistently" do + assert_raise(ActiveRecord::EagerLoadPolymorphicError) { authors(:david).essays.eager_load(:writer).to_a } + assert_raise(ActiveRecord::EagerLoadPolymorphicError) { authors(:david).essays.eager_load(:writer).count } + assert_raise(ActiveRecord::EagerLoadPolymorphicError) { authors(:david).essays.eager_load(:writer).exists? } end # CollectionProxy#reader is expensive, so the preloader avoids calling it. |