mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
do what the superclass does in the case that objects do not match
This commit is contained in:
parent
56bfd8a8c9
commit
096a57b7f3
2 changed files with 10 additions and 0 deletions
|
@ -312,6 +312,8 @@ module ActiveRecord
|
|||
def <=>(other_object)
|
||||
if other_object.is_a?(self.class)
|
||||
self.to_key <=> other_object.to_key
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -579,6 +579,14 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue