Skip to content

Commit c59e902

Browse files
author
David Heinemeier Hansson
committed
Add test verifying that you can only sort ARs of the same type
1 parent 430b252 commit c59e902

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

activerecord/test/cases/base_test.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,13 +554,19 @@ def test_hashing
554554
assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ]
555555
end
556556

557-
def test_comparison
557+
def test_successful_comparison_of_like_class_records
558558
topic_1 = Topic.create!
559559
topic_2 = Topic.create!
560560

561561
assert_equal [topic_2, topic_1].sort, [topic_1, topic_2]
562562
end
563563

564+
def test_failed_comparison_of_unlike_class_records
565+
assert_raises ArgumentError do
566+
[ topics(:first), posts(:welcome) ].sort
567+
end
568+
end
569+
564570
def test_create_without_prepared_statement
565571
topic = Topic.connection.unprepared_statement do
566572
Topic.create(:title => 'foo')

0 commit comments

Comments
 (0)