diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-08-25 16:36:55 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-08-25 16:36:55 +0900 |
commit | 1a723c65bbe91ad969b67416233d20eff6d2a46a (patch) | |
tree | a9f47b50453696ffcb8c41d1c28494cc4f23af63 /activerecord/test | |
parent | cb5af0d750198739d85b99aecd2f69927ec42e6a (diff) | |
download | rails-1a723c65bbe91ad969b67416233d20eff6d2a46a.tar.gz rails-1a723c65bbe91ad969b67416233d20eff6d2a46a.tar.bz2 rails-1a723c65bbe91ad969b67416233d20eff6d2a46a.zip |
Should work inverse association when eager loading
This regression was caused by caa178c1. The block for
`set_inverse_instance` should also be passed to join dependency.
Fixes #30402.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 1f5f9eddb5..44bf7f7d2f 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -40,6 +40,12 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_nil member.favourite_club end + def test_should_work_inverse_of_with_eager_load + author = authors(:david) + assert_same author, author.posts.first.author + assert_same author, author.posts.eager_load(:comments).first.author + end + def test_loading_with_one_association posts = Post.all.merge!(includes: :comments).to_a post = posts.find { |p| p.id == 1 } |