Skip to content
Browse files

do what the superclass does in the case that objects do not match

  • Loading branch information...
1 parent 56bfd8a commit 096a57b7f340884175f724b55c7bbeda6318b356 @tenderlove tenderlove committed
Showing with 10 additions and 0 deletions.
  1. +2 −0 activerecord/lib/active_record/core.rb
  2. +8 −0 activerecord/test/cases/base_test.rb
View
2 activerecord/lib/active_record/core.rb
@@ -312,6 +312,8 @@ def frozen?
def <=>(other_object)
if other_object.is_a?(self.class)
self.to_key <=> other_object.to_key
+ else
+ super
end
end
View
8 activerecord/test/cases/base_test.rb
@@ -579,6 +579,14 @@ def test_comparison_with_different_objects
assert_nil topic <=> category
end
+ def test_comparison_with_different_objects_in_array
+ topic = Topic.create
+ category = Category.create(:name => "comparison")
+ assert_raises(ArgumentError) do
+ [1, topic].sort
+ end
+ end
+
def test_readonly_attributes
assert_equal Set.new([ 'title' , 'comments_count' ]), ReadonlyTitlePost.readonly_attributes

0 comments on commit 096a57b

Please sign in to comment.
Something went wrong with that request. Please try again.