Permalink
Browse files

ActiveResource#eqls? and == should not take into account object ident…

…ity and prefix options should be considered. [#1098 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
1 parent 9a8e2a0 commit 6079ec1f77daf364a2b25cf651e9b3c9e1b95a16 @r6p r6p committed with lifo Jan 28, 2009
Showing with 11 additions and 2 deletions.
  1. +2 −2 activeresource/lib/active_resource/base.rb
  2. +9 −0 activeresource/test/base/equality_test.rb
@@ -746,8 +746,8 @@ def to_param
# # => true
#
def ==(other)
- other.equal?(self) || (other.instance_of?(self.class) && !other.new? && other.id == id)
- end
+ other.equal?(self) || (other.instance_of?(self.class) && other.id == id && other.prefix_options == prefix_options)
+ end
# Tests for equality (delegates to ==).
def eql?(other)
@@ -40,4 +40,13 @@ def test_hash_should_be_id_hash
assert_equal resource.id.hash, resource.hash
end
end
+
+ def test_with_prefix_options
+ assert_equal @one == @one, @one.eql?(@one)
+ assert_equal @one == @one.dup, @one.eql?(@one.dup)
+ new_one = @one.dup
+ new_one.prefix_options = {:foo => 'bar'}
+ assert_not_equal @one, new_one
+ end
+
end

0 comments on commit 6079ec1

Please sign in to comment.