Skip to content

Commit

Permalink
bug fix and test update
Browse files Browse the repository at this point in the history
  • Loading branch information
DarshanaVenkatesh committed Dec 5, 2024
1 parent cd52576 commit f8f39da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mongoid/equality.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Equality
#
# @return [ Integer ] -1, 0, 1.
def <=>(other)
return super unless other.is_a?(Mongoid::Equality)
attributes["_id"].to_s <=> other.attributes["_id"].to_s
end

Expand Down
6 changes: 6 additions & 0 deletions spec/mongoid/equality_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@
it "compares based on the document id" do
expect(first <=> second).to eq(-1)
end

it "doen't break if one isn't a document" do
expect do
first <=> "Foo"
end.to_not raise_error
end
end

describe "#eql?" do
Expand Down

0 comments on commit f8f39da

Please sign in to comment.