aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2018-10-04 11:03:24 -0400
committerGitHub <noreply@github.com>2018-10-04 11:03:24 -0400
commitddac80a951beb307d5d7adb781f6dd1d1f169f7e (patch)
treee35255c49833c6cb4b15d3774acb76f98c33d8f5 /activerecord/test/cases
parent414c70e072466ebe40e7c46795f27c48cba8d717 (diff)
parentd634c0d82b8ebd7b019baed535d89541bc8e4f6a (diff)
downloadrails-ddac80a951beb307d5d7adb781f6dd1d1f169f7e.tar.gz
rails-ddac80a951beb307d5d7adb781f6dd1d1f169f7e.tar.bz2
rails-ddac80a951beb307d5d7adb781f6dd1d1f169f7e.zip
Merge pull request #33938 from faucct/bugfix/preload_through_no_records
ActiveRecord::Associations::Preloader should not fail to preload through missing records
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/cascaded_eager_loading_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
index ba2104eb26..4cbc65b6d8 100644
--- a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
+++ b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
@@ -160,6 +160,11 @@ class CascadedEagerLoadingTest < ActiveRecord::TestCase
end
end
+ def test_preload_through_missing_records
+ post = Post.where.not(author_id: Author.select(:id)).preload(author: { comments: :post }).first!
+ assert_no_queries { assert_nil post.author }
+ end
+
def test_eager_association_loading_with_recursive_cascading_four_levels_has_many_through
source = Vertex.all.merge!(includes: { sinks: { sinks: { sinks: :sinks } } }, order: "vertices.id").first
assert_equal vertices(:vertex_4), assert_no_queries { source.sinks.first.sinks.first.sinks.first }