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:
parent
9a8e2a059c
commit
6079ec1f77
2 changed files with 11 additions and 2 deletions
|
@ -746,8 +746,8 @@ module ActiveResource
|
|||
# # => 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 @@ class BaseEqualityTest < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue