diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-28 04:42:38 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-28 04:42:38 +0900 |
commit | 3a0929901ffa852bab9644c662b811d42780c3a1 (patch) | |
tree | fe0a02591c61c8ebcdcfd19265f1289537089ad6 /activerecord/test/cases | |
parent | 0223665c971b98fe0ac82b78b485ee1330d4c1e3 (diff) | |
parent | 2847653869ffc1ff5139c46e520c72e26618c199 (diff) | |
download | rails-3a0929901ffa852bab9644c662b811d42780c3a1.tar.gz rails-3a0929901ffa852bab9644c662b811d42780c3a1.tar.bz2 rails-3a0929901ffa852bab9644c662b811d42780c3a1.zip |
Merge pull request #35496 from bogdan/right-preloading
Fix preloader to never reset associations in case they are already loaded
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/nested_through_associations_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/nested_through_associations_test.rb b/activerecord/test/cases/associations/nested_through_associations_test.rb index 0b83fd8421..35da74102d 100644 --- a/activerecord/test/cases/associations/nested_through_associations_test.rb +++ b/activerecord/test/cases/associations/nested_through_associations_test.rb @@ -548,6 +548,15 @@ class NestedThroughAssociationsTest < ActiveRecord::TestCase end end + def test_through_association_preload_doesnt_reset_source_association_if_already_preloaded + blue = tags(:blue) + authors = Author.preload(posts: :first_blue_tags_2, misc_post_first_blue_tags_2: {}).to_a.sort_by(&:id) + + assert_no_queries do + assert_equal [blue], authors[2].posts.first.first_blue_tags_2 + end + end + def test_nested_has_many_through_with_conditions_on_source_associations_preload_via_joins # Pointless condition to force single-query loading assert_includes_and_joins_equal( |