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:
parent
806d023b45
commit
37a4dd5ccf
1 changed files with 8 additions and 0 deletions
|
@ -695,6 +695,14 @@ class RelationTest < ActiveRecord::TestCase
|
||||||
assert_equal 1, comments.count
|
assert_equal 1, comments.count
|
||||||
end
|
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
|
def test_count
|
||||||
posts = Post.scoped
|
posts = Post.scoped
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue