Skip to content
Browse files

Testing objects equality is what we are looking for here, no query ca…

…ching.
  • Loading branch information...
1 parent cd6d6fc commit 21483cbc6755b1a8aae5bc2285fb439c22fb5265 @miloops miloops committed
Showing with 8 additions and 12 deletions.
  1. +8 −12 activerecord/test/cases/identity_map_test.rb
View
20 activerecord/test/cases/identity_map_test.rb
@@ -205,27 +205,23 @@ def test_find_with_included_associations
end
def test_eager_loading_with_conditions_on_joined_table_preloads
- posts = assert_queries(2) do
- Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
- end
+ posts = Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
assert_equal [posts(:welcome)], posts
assert_equal authors(:david), assert_no_queries { posts[0].author}
+ assert_same posts.first.author.target, Author.first
- posts = assert_queries(1) do
- Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
- end
+ posts = Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
assert_equal [posts(:welcome)], posts
assert_equal authors(:david), assert_no_queries { posts[0].author}
+ assert_same posts.first.author.target, Author.first
- posts = assert_queries(1) do
- Post.find(:all, :include => :author, :joins => {:taggings => :tag}, :conditions => "tags.name = 'General'", :order => 'posts.id')
- end
+ posts = Post.find(:all, :include => :author, :joins => {:taggings => :tag}, :conditions => "tags.name = 'General'", :order => 'posts.id')
assert_equal posts(:welcome, :thinking), posts
+ assert_same posts.first.author.target, Author.first
- posts = assert_queries(1) do
- Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id')
- end
+ posts = Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id')
assert_equal posts(:welcome, :thinking), posts
+ assert_same posts.first.author.target, Author.first
end
def test_eager_loading_with_conditions_on_string_joined_table_preloads

0 comments on commit 21483cb

Please sign in to comment.
Something went wrong with that request. Please try again.