1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Testing objects equality is what we are looking for here, no query caching.

This commit is contained in:
Emilio Tagua 2010-09-21 17:46:20 -03:00
parent cd6d6fcb23
commit 21483cbc67

View file

@ -205,27 +205,23 @@ class IdentityMapTest < ActiveRecord::TestCase
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