Skip to content

Commit

Permalink
Cache metadata in advance to avoid extra sql statements while testing.
Browse files Browse the repository at this point in the history
Reason: If metadata is not cached extra sql statements
will be executed, which causes failures tests with assert_queries().
  • Loading branch information
pmahoney committed May 25, 2012
1 parent 873b0e2 commit 3f74ba3
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -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
Expand Down

0 comments on commit 3f74ba3

Please sign in to comment.