Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 096a57b7f340884175f724b55c7bbeda6318b356 1 parent 56bfd8a
@tenderlove tenderlove authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.