Skip to content
This repository
Browse code

Merge pull request #6605 from amatsuda/ar_merge_association_test

a test case that ensures AR::Relation#merge can merge associations
  • Loading branch information...
commit 9dbcaeb9bc03c66f0072d970543c4d020f317d7e 2 parents 806d023 + 37a4dd5
Jon Leighton jonleighton authored

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. +8 0 activerecord/test/cases/relations_test.rb
8 activerecord/test/cases/relations_test.rb
@@ -695,6 +695,14 @@ def test_relation_merging_with_joins
695 695 assert_equal 1, comments.count
696 696 end
697 697
  698 + def test_relation_merging_with_association
  699 + assert_queries(2) do # one for loading post, and another one merged query
  700 + post = Post.where(:body => 'Such a lovely day').first
  701 + comments = Comment.where(:body => 'Thank you for the welcome').merge(post.comments)
  702 + assert_equal 1, comments.count
  703 + end
  704 + end
  705 +
698 706 def test_count
699 707 posts = Post.scoped
700 708

0 comments on commit 9dbcaeb

Please sign in to comment.
Something went wrong with that request. Please try again.