Skip to content

service: Delete all service errors when removed#44

Merged
bors[bot] merged 1 commit intomasterfrom
change/delete_service_errors
Jul 4, 2018
Merged

service: Delete all service errors when removed#44
bors[bot] merged 1 commit intomasterfrom
change/delete_service_errors

Conversation

@miguelsorianod
Copy link
Copy Markdown
Contributor

When a Service is deleted, all of its errors should be deleted.

def delete_data
delete_from_lists
delete_attributes
ErrorStorage.delete_all(id)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine 👍

Comment thread spec/unit/service_spec.rb

it 'deletes all service errors' do
Service.save! id: 7002, provider_key: 'foo', default_service: true
ErrorStorage.store(service.id, ApplicationNotFound.new('foo'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would store at least 2 to make sure that this works correctly and does not delete just one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread spec/unit/service_spec.rb Outdated
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean

expect { Service.delete_by_id(service.id) }.to  change { ErrorStorage.count(service.id) }.from(2?).to(0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@eguzki
Copy link
Copy Markdown
Member

eguzki commented Jul 3, 2018

LGTM

Maybe adding a test trying to delete when there is nothing to delete?? It should not fail or raise any error

@miguelsorianod
Copy link
Copy Markdown
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.
@miguelsorianod miguelsorianod force-pushed the change/delete_service_errors branch from df2008f to 44e056d Compare July 4, 2018 08:33
@miguelsorianod
Copy link
Copy Markdown
Contributor Author

Changes have been added

@miguelsorianod
Copy link
Copy Markdown
Contributor Author

bors r=@davidor,@eguzki

bors Bot added a commit that referenced this pull request Jul 4, 2018
44: service: Delete all service errors when removed r=davidor,eguzki a=miguelsorianod

When a Service is deleted, all of its errors should be deleted.

Co-authored-by: Miguel Soriano <msoriano@redhat.com>
@bors
Copy link
Copy Markdown
Contributor

bors Bot commented Jul 4, 2018

Build succeeded

@bors bors Bot merged commit 44e056d into master Jul 4, 2018
@bors bors Bot deleted the change/delete_service_errors branch July 4, 2018 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants