diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 8b384c2513147..fe64692df6718 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -1339,6 +1339,9 @@ def test_custom_primary_key_on_new_record_should_fetch_with_query author = Author.new(:name => "David") assert !author.essays.loaded? + # cache metadata in advance to avoid extra sql statements executed while testing + Essay.first + assert_queries 1 do assert_equal 1, author.essays.size end