Skip to content

Commit

Permalink
Update number of queries executed instead of avoiding IM.
Browse files Browse the repository at this point in the history
  • Loading branch information
miloops committed Nov 19, 2010
1 parent 7892543 commit 6cd1224
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions activerecord/test/cases/relations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,12 @@ def test_eager_association_loading_of_stis_with_multiple_references
end

def test_find_with_preloaded_associations
ActiveRecord::IdentityMap.without do
assert_queries(2) do
posts = Post.preload(:comments)
assert posts.first.comments.first
end

assert_queries(2) do
assert_queries(1) do
posts = Post.preload(:comments).to_a
assert posts.first.comments.first
end
Expand All @@ -279,27 +278,25 @@ def test_find_with_preloaded_associations
assert posts.first.author
end

assert_queries(2) do
assert_queries(1) do
posts = Post.preload(:author).to_a
assert posts.first.author
end

assert_queries(3) do
assert_queries(1) do
posts = Post.preload(:author, :comments).to_a
assert posts.first.author
assert posts.first.comments.first
end
end
end

def test_find_with_included_associations
ActiveRecord::IdentityMap.without do
assert_queries(2) do
posts = Post.includes(:comments)
assert posts.first.comments.first
end

assert_queries(2) do
assert_queries(1) do
posts = Post.scoped.includes(:comments)
assert posts.first.comments.first
end
Expand All @@ -309,12 +306,11 @@ def test_find_with_included_associations
assert posts.first.author
end

assert_queries(3) do
assert_queries(1) do
posts = Post.includes(:author, :comments).to_a
assert posts.first.author
assert posts.first.comments.first
end
end
end

def test_default_scope_with_conditions_string
Expand Down

0 comments on commit 6cd1224

Please sign in to comment.