From 37a4dd5ccf912e853e1e75f978c1c36d0fa98b5f Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 29 Mar 2012 12:10:25 +0900 Subject: a test case that ensures AR::Relation#merge can merge associations --- activerecord/test/cases/relations_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 90367df5ee..6c5bee7382 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -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 -- cgit v1.2.3