rails--rails/actionview/test/activerecord
aaron 432698ef2b
Fix `SELECT COUNT` queries when rendering ActiveRecord collections (#40870)
* Fix `SELECT COUNT` queries when rendering ActiveRecord collections

Fixes #40837

When rendering collections, calling `size` when the collection is an
ActiveRecord relation causes unwanted `SELECT COUNT(*)` queries. This
change ensures the collection is an array before getting the size, and
also loads the relation for any further array inspections.

* Test queries when rendering relation collections

* Add `length` support to partial collection iterator

Allows getting the size of a relation without duplicating records, but
still loads the relation. The length method existence needs to be
checked because you can pass in an `Enumerator`, which does not respond
to `length`.

* Ensure unsubscribed from notifications after tests

[Rafael Mendonça França + aar0nr]
2020-12-18 15:58:11 -05:00
..
controller_runtime_test.rb Add allocations to template renderer subscription 2018-10-10 08:07:12 -04:00
debug_helper_test.rb Change the empty block style to have space inside of the block 2018-09-25 13:19:35 -04:00
form_helper_activerecord_test.rb Enable `Layout/EmptyLinesAroundAccessModifier` cop 2019-06-13 12:00:45 +09:00
multifetch_cache_test.rb pull preloading behavior in to the collection renderer 2020-02-28 09:23:22 -08:00
partial_rendering_query_test.rb Fix `SELECT COUNT` queries when rendering ActiveRecord collections (#40870) 2020-12-18 15:58:11 -05:00
polymorphic_routes_test.rb Address to false negative for Performance/DeletePrefix,DeleteSuffix 2020-06-14 13:04:47 +09:00
relation_cache_test.rb Remove redundant @virtual_path variable 2020-05-26 15:53:11 -04:00
render_partial_with_record_identification_test.rb Remove deprecated catch-all route in the AV tests 2018-09-24 15:39:15 -07:00