2021-03-13 15:04:57 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
require 'webmock/rspec'
|
|
|
|
|
|
2021-03-13 15:22:19 -08:00
|
|
|
describe External::MailblusterHelper, type: :helper do
|
2021-03-13 15:04:57 -08:00
|
|
|
let!(:user) { create(:user) }
|
|
|
|
|
|
|
|
|
|
describe 'create_lead' do
|
|
|
|
|
it 'makes a post request to Mailbluster\'s API' do
|
2021-03-14 13:25:36 -07:00
|
|
|
stub_request(:post, "http://api.mailbluster.com/api/leads")
|
|
|
|
|
.to_return(body: '{
|
|
|
|
|
"message": "Lead created",
|
|
|
|
|
"lead": {
|
|
|
|
|
"id": 329395,
|
|
|
|
|
"firstName": "Richard",
|
|
|
|
|
"lastName": "Hendricks",
|
|
|
|
|
"fullName": "Richard Hendricks",
|
|
|
|
|
"email": "richard@example.com",
|
|
|
|
|
"timezone": "America/Los_Angeles",
|
|
|
|
|
"ipAddress": "162.213.1.246",
|
|
|
|
|
"subscribed": false,
|
|
|
|
|
"meta": {
|
|
|
|
|
"company": "Pied Piper",
|
|
|
|
|
"role": "CEO",
|
|
|
|
|
"continent": "North America",
|
|
|
|
|
"country": "United States",
|
|
|
|
|
"city": "San Jose",
|
|
|
|
|
"latitude": 37.3008,
|
|
|
|
|
"longitude": -121.9777,
|
|
|
|
|
"source": "Lead API"
|
|
|
|
|
},
|
|
|
|
|
"tags": [
|
|
|
|
|
"iPhone User",
|
|
|
|
|
"Startup"
|
|
|
|
|
],
|
|
|
|
|
"createdAt": "2016-07-23T08:03:18.954Z",
|
|
|
|
|
"updatedAt": "2016-07-23T08:03:18.954Z"
|
|
|
|
|
}
|
|
|
|
|
}', status: 200)
|
2021-03-13 15:29:25 -08:00
|
|
|
create_lead(user)
|
2021-03-14 13:25:36 -07:00
|
|
|
expect(WebMock).to have_requested(:post, "api.mailbluster.com/api/leads")
|
2021-03-13 15:04:57 -08:00
|
|
|
end
|
|
|
|
|
end
|
2021-03-13 15:22:19 -08:00
|
|
|
end
|