From d634c0d82b8ebd7b019baed535d89541bc8e4f6a Mon Sep 17 00:00:00 2001 From: Nikita Sokolov Date: Fri, 21 Sep 2018 10:53:00 +0300 Subject: ActiveRecord::Associations::Preloader should not fail to preload through missing records --- activerecord/test/cases/associations/cascaded_eager_loading_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/test/cases/associations') 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 } -- cgit v1.2.3