class EagerLoadNestedIncludeWithMissingDataTest

Public Instance Methods

setup() click to toggle source
# File activerecord/test/cases/associations/eager_load_nested_include_test.rb, line 105
def setup
  @davey_mcdave = Author.create(name: "Davey McDave")
  @first_post = @davey_mcdave.posts.create(title: "Davey Speaks", body: "Expressive wordage")
  @first_comment = @first_post.comments.create(body: "Inflamatory doublespeak")
  @first_categorization = @davey_mcdave.categorizations.create(category: Category.first, post: @first_post)
end
test_missing_data_in_a_nested_include_should_not_cause_errors_when_constructing_objects() click to toggle source
# File activerecord/test/cases/associations/eager_load_nested_include_test.rb, line 119
def test_missing_data_in_a_nested_include_should_not_cause_errors_when_constructing_objects
  assert_nothing_raised do
    # @davey_mcdave doesn't have any author_favorites
    includes = { posts: :comments, categorizations: :category, author_favorites: :favorite_author }
    Author.all.merge!(includes: includes, where: { authors: { name: @davey_mcdave.name } }, order: "categories.name").to_a
  end
end