Created
November 16, 2010 14:23
-
-
Save spastorino/701871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb | |
index e29c6c2..d65dc6b 100644 | |
--- a/activerecord/lib/active_record/base.rb | |
+++ b/activerecord/lib/active_record/base.rb | |
@@ -1610,9 +1610,9 @@ MSG | |
# Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id. | |
def ==(comparison_object) | |
comparison_object.equal?(self) || | |
- persisted? && | |
- (comparison_object.instance_of?(self.class) && | |
- comparison_object.id == id) | |
+ comparison_object.instance_of?(self.class) && | |
+ id.present? && | |
+ comparison_object.id == id | |
end | |
# Delegates to == | |
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb | |
index 6d46058..d503658 100644 | |
--- a/activerecord/test/cases/base_test.rb | |
+++ b/activerecord/test/cases/base_test.rb | |
@@ -388,6 +388,9 @@ class BasicsTest < ActiveRecord::TestCase | |
assert_not_equal Topic.new, Topic.new | |
end | |
+ def test_equality_of_destroyed_records | |
+ end | |
+ | |
def test_hashing | |
assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ] | |
end | |
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb | |
index 3d6975d..e6b8d79 100644 | |
--- a/activerecord/test/cases/named_scope_test.rb | |
+++ b/activerecord/test/cases/named_scope_test.rb | |
@@ -122,7 +122,7 @@ class NamedScopeTest < ActiveRecord::TestCase | |
:joins => 'JOIN authors ON authors.id = posts.author_id', | |
:conditions => [ 'authors.author_address_id = ?', address.id ] | |
) | |
- assert_equal posts_with_authors_at_address_titles, Post.with_authors_at_address(address).find(:all, :select => 'title') | |
+ assert_equal posts_with_authors_at_address_titles.map(&:title), Post.with_authors_at_address(address).find(:all, :select => 'title').map(&:title) | |
end | |
def test_extensions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment