aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-06-28 11:46:25 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-06-28 11:46:25 -0700
commita5cb5a5af611481e7a69b160983fcac68f37088c (patch)
treef79d9c929d616f0b0d6bd1233cc44bf4c673fc41 /activerecord/test
parent26caf32949f40993409f71887b2490722749022a (diff)
parenteb22c51173f3ebe0f5a53f8bc57ebc74e4f0a824 (diff)
downloadrails-a5cb5a5af611481e7a69b160983fcac68f37088c.tar.gz
rails-a5cb5a5af611481e7a69b160983fcac68f37088c.tar.bz2
rails-a5cb5a5af611481e7a69b160983fcac68f37088c.zip
Merge pull request #1860 from dmathieu/comparison
Allow comparison on model objects - Closes #1858
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/base_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 2224097f04..5fef3faab9 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -478,6 +478,19 @@ class BasicsTest < ActiveRecord::TestCase
def test_hashing
assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ]
end
+
+ def test_comparison
+ topic_1 = Topic.create!
+ topic_2 = Topic.create!
+
+ assert_equal [topic_2, topic_1].sort, [topic_1, topic_2]
+ end
+
+ def test_comparison_with_different_objects
+ topic = Topic.create
+ category = Category.create(:name => "comparison")
+ assert_nil topic <=> category
+ end
def test_readonly_attributes
assert_equal Set.new([ 'title' , 'comments_count' ]), ReadonlyTitlePost.readonly_attributes