-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEV-1124: holdings are equal if fields are equal or both empty #299
Conversation
spec/clusterable/holding_spec.rb
Outdated
end | ||
|
||
(described_class.fields.keys - ["date_received", "uuid", "_id"]).each do |attr| | ||
it "== is false if #{attr} doesn't match" do | ||
h2[attr] = nil | ||
expect(h == h2).to be(false) | ||
# ensure attribute in h2 is different from h but |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, we were always setting h2[attr]
to nil, so the behavior change made this test fail -- now it sets it to an appropriate non-nil but non-equal type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Just fix the standardrb warnings.
APPROVE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, I meant to actually approve not just say "APPROVE".
APPROVE.
… blank The holdings matching function used update_key (a modified hash value) rather than equality; this update folds empty string & nil for computing that update_key as well.
@mwarin I added a test to cover the actual update situation, which revealed that for performance we were using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran tests (green), looked at code (makes sense), saw new test (good).
APPROVE.
This should address the underlying issue we were seeing with duplicate holdings not being cleaned up.
It probably would not hurt to add a test case that exercises the specific issue we were seeing -- create a cluster with a holding with some nil fields, update it with a holding with corresponding empty-string fields; ensure that they match and it doesn't end up with duplicate holdings. I will work on that next week, but wanted to get something up for a look now.