1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #42274 from martinjaimem/fix/without-argument-error-message

Fix ArgumentError message for without method
This commit is contained in:
Ryuta Kamizono 2021-05-23 06:21:47 +09:00 committed by GitHub
commit e888e3cf87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -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)

View file

@ -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