aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-06-03 01:20:31 -0700
committerJon Leighton <j@jonathanleighton.com>2012-06-03 01:20:31 -0700
commit9dbcaeb9bc03c66f0072d970543c4d020f317d7e (patch)
treeef183128f13d7b9a15faffba1bbc9d22e92c9efd
parent806d023b4563f907f1b93278f19fe00e77c434c6 (diff)
parent37a4dd5ccf912e853e1e75f978c1c36d0fa98b5f (diff)
downloadrails-9dbcaeb9bc03c66f0072d970543c4d020f317d7e.tar.gz
rails-9dbcaeb9bc03c66f0072d970543c4d020f317d7e.tar.bz2
rails-9dbcaeb9bc03c66f0072d970543c4d020f317d7e.zip
Merge pull request #6605 from amatsuda/ar_merge_association_test
a test case that ensures AR::Relation#merge can merge associations
-rw-r--r--activerecord/test/cases/relations_test.rb8
1 files changed, 8 insertions, 0 deletions
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