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
Add method to destroy a MailJet contact #58012
Add method to destroy a MailJet contact #58012
Conversation
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.
Looks great!
|
||
Net::HTTP.any_instance.expects(:request).with(mock_http_request) | ||
|
||
MailJet.delete_contact(email) |
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.
Nit: could there be another use of Mailjet::Contact.expects(:find).with(email).returns(mock_contact)
after this last line but with .returns(nil)
instead to confirm it was deleted?
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.
I'm not sure that would confirm it's actually deleted though, because we're not actually calling the MailJet service. Or am I misunderstanding?
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.
Oh gotcha, I thought maybe we could check it with that line to have the format of 1) check that it returns the mock_contact like you'd expect, 2) delete it, 3) have the same check but expect it to be nil sort of deal. Totally fine if that wouldn't work!
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.
When I walk through those steps, I'm not sure what you're imagining for step 3. Can you maybe write some pseudocode?
For clarity, what I'm understanding is:
- to change line 76 to be
Mailjet::Contact.expects(:find).with(email).returns(mock_contact).then.returns(nil)
-
already done in line 84!
-
not sure
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.
Resolved offline: I misunderstood what the line was doing and this test makes sense!
Adds a method to destroy a MailJet contact. In a follow-up, I'll call this as part of the account purger.
Note that, for some reason, the API to delete a contact is only available through cURL.