1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

ActiveResource#eqls? and == should not take into account object identity and prefix options should be considered. [#1098 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
Rasik Pandey 2009-01-28 19:39:06 +00:00 committed by Pratik Naik
parent 9a8e2a059c
commit 6079ec1f77
2 changed files with 11 additions and 2 deletions

View file

@ -746,8 +746,8 @@ module ActiveResource
# # => true # # => true
# #
def ==(other) def ==(other)
other.equal?(self) || (other.instance_of?(self.class) && !other.new? && other.id == id) other.equal?(self) || (other.instance_of?(self.class) && other.id == id && other.prefix_options == prefix_options)
end end
# Tests for equality (delegates to ==). # Tests for equality (delegates to ==).
def eql?(other) def eql?(other)

View file

@ -40,4 +40,13 @@ class BaseEqualityTest < Test::Unit::TestCase
assert_equal resource.id.hash, resource.hash assert_equal resource.id.hash, resource.hash
end end
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 end