From 15da1fb35b41a94bdd6b75b249f83572400843d7 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 24 Feb 2019 08:23:43 +0900 Subject: [PATCH] Add test case for `unscope` with unknown column --- activerecord/test/cases/relations_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index b28e2910bb..61b69f2de5 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1941,6 +1941,17 @@ class RelationTest < ActiveRecord::TestCase assert_equal p2.first.comments, comments end + def test_unscope_with_unknown_column + comment = comments(:greetings) + comment.update!(comments: 1) + + comments = Comment.where(comments: 1).unscope(where: :unknown_column) + assert_equal [comment], comments + + comments = Comment.where(comments: 1).unscope(where: { comments: :unknown_column }) + assert_equal [comment], comments + end + def test_unscope_specific_where_value posts = Post.where(title: "Welcome to the weblog", body: "Such a lovely day")