Add spec for deleting leads

This commit is contained in:
CactusPuppy 2021-03-16 15:22:28 -07:00
parent 59908e60e4
commit fddd6ecd9f
No known key found for this signature in database
GPG key ID: 4B33B0A3E15E2C82

View file

@ -36,4 +36,17 @@ describe External::MailblusterHelper, type: :helper do
expect(response).to eq(response_body)
end
end
describe 'delete_lead' do
it 'correctly requests the right URL and gets a valid response' do
email_hash = Digest::MD5.hexdigest user.email
response_body = "{\"message\":\"Lead deleted\",\"leadHash\":\"#{email_hash}\"}"
stub_request(:delete, "https://api.mailbluster.com/api/leads/#{email_hash}")
.to_return(body: response_body)
response = delete_lead(user)
expect(WebMock).to have_requested(:delete, "api.mailbluster.com/api/leads/#{email_hash}")
expect(response).to eq(response_body)
end
end
end