Skip to content

Commit

Permalink
Fix ArgumentError message for without method
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Jaime committed May 22, 2021
1 parent 3bd6b68 commit 70dec80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -1162,7 +1162,7 @@ def excluding(*records)
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)
Expand Down
3 changes: 3 additions & 0 deletions activerecord/test/cases/excluding_test.rb
Expand Up @@ -48,6 +48,9 @@ def test_does_not_exclude_records_when_no_arguments
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
Expand Down

0 comments on commit 70dec80

Please sign in to comment.