aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-03-29 04:27:23 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2014-03-29 04:34:20 -0700
commit945dd254ae4a79705c2c05a683fc37a8c98c8aeb (patch)
treecd99f279cdd67180122db5ba20851cb4e2b9ba7f /activerecord/test/cases/base_test.rb
parent86c53d510cf31b792a7e96a44535e64b3983d17a (diff)
downloadrails-945dd254ae4a79705c2c05a683fc37a8c98c8aeb.tar.gz
rails-945dd254ae4a79705c2c05a683fc37a8c98c8aeb.tar.bz2
rails-945dd254ae4a79705c2c05a683fc37a8c98c8aeb.zip
Ensure we are returning either `true` or `false` for `#==`
460eb83d cused `ActiveRecord::Base#==` to sometimes return `nil` in some cases, this ensures we always return a boolean value. Also fixed a similar problem in AR reflections.
Diffstat (limited to 'activerecord/test/cases/base_test.rb')
-rw-r--r--activerecord/test/cases/base_test.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 6acb342d0b..4969344763 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -533,6 +533,7 @@ class BasicsTest < ActiveRecord::TestCase
def test_equality_of_new_records
assert_not_equal Topic.new, Topic.new
+ assert_equal false, Topic.new == Topic.new
end
def test_equality_of_destroyed_records
@@ -544,6 +545,12 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal topic_2, topic_1
end
+ def test_equality_with_blank_ids
+ one = Subscriber.new(:id => '')
+ two = Subscriber.new(:id => '')
+ assert_equal one, two
+ end
+
def test_hashing
assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ]
end
@@ -578,12 +585,6 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal nil, Topic.find_by_id(topic.id)
end
- def test_blank_ids
- one = Subscriber.new(:id => '')
- two = Subscriber.new(:id => '')
- assert_equal one, two
- end
-
def test_comparison_with_different_objects
topic = Topic.create
category = Category.create(:name => "comparison")