Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 6079ec1f77daf364a2b25cf651e9b3c9e1b95a16 1 parent 9a8e2a0
@r6p r6p authored lifo committed
View
4 activeresource/lib/active_resource/base.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)
View
9 activeresource/test/base/equality_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.