diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-24 18:30:20 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-24 18:30:20 +0900 |
commit | 257564d65a87bd2cccfd4ef78ae4b9a49c476f5d (patch) | |
tree | 25140b5911c40fdec0e990fdd794c8a97990fa10 /activerecord/test | |
parent | 812e59bfa3a3462452b2b5e47e2937cd994f2aa9 (diff) | |
download | rails-257564d65a87bd2cccfd4ef78ae4b9a49c476f5d.tar.gz rails-257564d65a87bd2cccfd4ef78ae4b9a49c476f5d.tar.bz2 rails-257564d65a87bd2cccfd4ef78ae4b9a49c476f5d.zip |
Add test case for `unscope` with `merge`
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 61b69f2de5..2de0a81c99 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1941,6 +1941,19 @@ class RelationTest < ActiveRecord::TestCase 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) |