Skip to content
This repository
Browse code

Fix number of queries performed in tests.

  • Loading branch information...
commit 4015819adac4e4fcc96a3da4c9873359ea6ce230 1 parent 9fe0dbf
Emilio Tagua authored October 20, 2010
12  activerecord/test/cases/associations/eager_test.rb
@@ -170,7 +170,7 @@ def test_finding_with_includes_on_has_one_assocation_with_same_include_includes_
170 170
     author = authors(:david)
171 171
     post = author.post_about_thinking_with_last_comment
172 172
     last_comment = post.last_comment
173  
-    author = assert_queries(3) { Author.find(author.id, :include => {:post_about_thinking_with_last_comment => :last_comment})} # find the author, then find the posts, then find the comments
  173
+    author = assert_queries(2) { Author.find(author.id, :include => {:post_about_thinking_with_last_comment => :last_comment})} # find the author, then find the posts, then find the comments
174 174
     assert_no_queries do
175 175
       assert_equal post, author.post_about_thinking_with_last_comment
176 176
       assert_equal last_comment, author.post_about_thinking_with_last_comment.last_comment
@@ -181,7 +181,7 @@ def test_finding_with_includes_on_belongs_to_association_with_same_include_inclu
181 181
     post = posts(:welcome)
182 182
     author = post.author
183 183
     author_address = author.author_address
184  
-    post = assert_queries(3) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author, then find the address
  184
+    post = assert_queries(2) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author, then find the address
185 185
     assert_no_queries do
186 186
       assert_equal author, post.author_with_address
187 187
       assert_equal author_address, post.author_with_address.author_address
@@ -789,18 +789,18 @@ def test_eager_loading_with_conditions_on_joined_table_preloads
789 789
     assert_equal [posts(:welcome)], posts
790 790
     assert_equal authors(:david), assert_no_queries { posts[0].author}
791 791
 
792  
-    posts = assert_queries(2) do
  792
+    posts = assert_queries(1) do
793 793
       Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
794 794
     end
795 795
     assert_equal [posts(:welcome)], posts
796 796
     assert_equal authors(:david), assert_no_queries { posts[0].author}
797 797
 
798  
-    posts = assert_queries(2) do
  798
+    posts = assert_queries(1) do
799 799
       Post.find(:all, :include => :author, :joins => {:taggings => :tag}, :conditions => "tags.name = 'General'", :order => 'posts.id')
800 800
     end
801 801
     assert_equal posts(:welcome, :thinking), posts
802 802
 
803  
-    posts = assert_queries(2) do
  803
+    posts = assert_queries(1) do
804 804
       Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id')
805 805
     end
806 806
     assert_equal posts(:welcome, :thinking), posts
@@ -814,7 +814,7 @@ def test_eager_loading_with_conditions_on_string_joined_table_preloads
814 814
     assert_equal [posts(:welcome)], posts
815 815
     assert_equal authors(:david), assert_no_queries { posts[0].author}
816 816
 
817  
-    posts = assert_queries(2) do
  817
+    posts = assert_queries(1) do
818 818
       Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => ["INNER JOIN comments on comments.post_id = posts.id"], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
819 819
     end
820 820
     assert_equal [posts(:welcome)], posts

0 notes on commit 4015819

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