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

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

This commit is contained in:
Akira Matsuda 2012-03-29 12:10:25 +09:00
parent 806d023b45
commit 37a4dd5ccf

View file

@ -695,6 +695,14 @@ class RelationTest < ActiveRecord::TestCase
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