Permalink
Browse files

a test case that ensures AR::Relation#merge can merge associations

  • Loading branch information...
1 parent 806d023 commit 37a4dd5ccf912e853e1e75f978c1c36d0fa98b5f @amatsuda amatsuda committed Mar 29, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 activerecord/test/cases/relations_test.rb
@@ -695,6 +695,14 @@ def test_relation_merging_with_joins
assert_equal 1, comments.count
end
+ def test_relation_merging_with_association
+ assert_queries(2) do # one for loading post, and another one merged query
+ post = Post.where(:body => 'Such a lovely day').first
+ comments = Comment.where(:body => 'Thank you for the welcome').merge(post.comments)
+ assert_equal 1, comments.count
+ end
+ end
+
def test_count
posts = Post.scoped

0 comments on commit 37a4dd5

Please sign in to comment.