From 70dec80388965074d51ebffa5e57526a426d3556 Mon Sep 17 00:00:00 2001 From: Martin Jaime Date: Sat, 22 May 2021 16:53:53 -0300 Subject: [PATCH] Fix ArgumentError message for without method --- activerecord/lib/active_record/relation/query_methods.rb | 2 +- activerecord/test/cases/excluding_test.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 5c3c0513dc..eec05e9458 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -1162,7 +1162,7 @@ module ActiveRecord records.compact! unless records.all?(klass) - raise ArgumentError, "You must only pass a single or collection of #{klass.name} objects to #excluding." + raise ArgumentError, "You must only pass a single or collection of #{klass.name} objects to ##{__callee__}." end spawn.excluding!(records) diff --git a/activerecord/test/cases/excluding_test.rb b/activerecord/test/cases/excluding_test.rb index e2fb7d61a3..2d120db10c 100644 --- a/activerecord/test/cases/excluding_test.rb +++ b/activerecord/test/cases/excluding_test.rb @@ -48,6 +48,9 @@ class ExcludingTest < ActiveRecord::TestCase def test_raises_on_record_from_different_class error = assert_raises(ArgumentError) { Post.excluding(@post, comments(:greetings)) } assert_equal "You must only pass a single or collection of Post objects to #excluding.", error.message + + error = assert_raises(ArgumentError) { Post.without(@post, comments(:greetings)) } + assert_equal "You must only pass a single or collection of Post objects to #without.", error.message end private