From 945a82b5c0aad6bd6af656865015277d3e0e612b Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 29 Jun 2023 14:42:54 +0000 Subject: <=> operator should return nil when invoked with an incomparable object (#38772). Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@22269 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/enumeration_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/unit/enumeration_test.rb b/test/unit/enumeration_test.rb index 25dfb14c4..a9d0e8eb3 100644 --- a/test/unit/enumeration_test.rb +++ b/test/unit/enumeration_test.rb @@ -179,4 +179,10 @@ class EnumerationTest < ActiveSupport::TestCase override.destroy assert_equal [1, 2, 3], [a, b, c].map(&:reload).map(&:position) end + + def test_spaceship_operator_with_incomparable_value_should_return_nil + e = Enumeration.first + assert_nil e <=> nil + assert_nil e <=> 'foo' + end end -- cgit v1.2.3