Skip to content

Commit

Permalink
Add test case for unscope with merge
Browse files Browse the repository at this point in the history
  • Loading branch information
kamipo committed Feb 24, 2019
1 parent 812e59b commit 257564d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions activerecord/test/cases/relations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1941,6 +1941,19 @@ def test_unscope_with_subquery
assert_equal p2.first.comments, comments
end

def test_unscope_with_merge
p0 = Post.where(author_id: 0)
p1 = Post.where(author_id: 1, comments_count: 1)

assert_equal [posts(:authorless)], p0
assert_equal [posts(:thinking)], p1

comments = Comment.merge(p0).unscope(where: :author_id).where(post: p1)

assert_not_equal p0.first.comments, comments
assert_equal p1.first.comments, comments
end

def test_unscope_with_unknown_column
comment = comments(:greetings)
comment.update!(comments: 1)
Expand Down

0 comments on commit 257564d

Please sign in to comment.