Permalink
Browse files

Merge pull request #6605 from amatsuda/ar_merge_association_test

a test case that ensures AR::Relation#merge can merge associations
  • Loading branch information...
2 parents 806d023 + 37a4dd5 commit 9dbcaeb9bc03c66f0072d970543c4d020f317d7e @jonleighton jonleighton committed Jun 3, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 activerecord/test/cases/relations_test.rb
View
8 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 9dbcaeb

Please sign in to comment.