service: Delete all service errors when removed#44
Merged
Conversation
miguelsorianod
commented
Jul 3, 2018
| def delete_data | ||
| delete_from_lists | ||
| delete_attributes | ||
| ErrorStorage.delete_all(id) |
Contributor
Author
There was a problem hiding this comment.
We call delete directly on the list in ErrorStorage because it has at most 1000 entries (defined in MAX_NUM_ERRORS in error_storage.rb)
davidor
reviewed
Jul 3, 2018
|
|
||
| it 'deletes all service errors' do | ||
| Service.save! id: 7002, provider_key: 'foo', default_service: true | ||
| ErrorStorage.store(service.id, ApplicationNotFound.new('foo')) |
Contributor
There was a problem hiding this comment.
I would store at least 2 to make sure that this works correctly and does not delete just one.
davidor
reviewed
Jul 3, 2018
| Service.save! id: 7002, provider_key: 'foo', default_service: true | ||
| ErrorStorage.store(service.id, ApplicationNotFound.new('foo')) | ||
|
|
||
| expect(ErrorStorage.count(service.id)).to be > 0 |
Contributor
There was a problem hiding this comment.
With the pattern: expect, do_something, expect, I prefer to use to_change:
expect { Service.delete_by_id(service.id) }
.to_change(ErrorStorage.count(service.id))
.from(2?)
.to(0)
Member
There was a problem hiding this comment.
I think you mean
expect { Service.delete_by_id(service.id) }.to change { ErrorStorage.count(service.id) }.from(2?).to(0)
Member
|
LGTM Maybe adding a test trying to delete when there is nothing to delete?? It should not fail or raise any error |
Contributor
Author
|
About adding a test for deleting when there's nothing to delete, I thought about that too and seems a good idea so I'll add it |
When a Service is deleted, all of its errors should be deleted.
df2008f to
44e056d
Compare
Contributor
Author
|
Changes have been added |
davidor
approved these changes
Jul 4, 2018
eguzki
approved these changes
Jul 4, 2018
Contributor
Author
Contributor
Build succeeded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Service is deleted, all of its errors should be deleted.