Upstream sync
This commit is contained in:
@@ -11,10 +11,12 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
|
||||
allow(Hubspot::Form).to receive(:new).and_return(form)
|
||||
allow(form).to receive(:submit).and_return(true)
|
||||
|
||||
SubmitHubspotFormJob.perform_now("email@test.com", "My Account")
|
||||
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account")
|
||||
|
||||
expect(Hubspot::Form).to have_received(:new).with("guid" => "hubspot_form_guid")
|
||||
expect(form).to have_received(:submit).with(
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "email@test.com",
|
||||
company: "My Account"
|
||||
)
|
||||
@@ -25,9 +27,11 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
|
||||
allow(Hubspot::Form).to receive(:new).and_return(form)
|
||||
allow(form).to receive(:submit).and_return(true)
|
||||
|
||||
SubmitHubspotFormJob.perform_now("email@test.com", "My Account", additional_param_one: "Foo", additional_param_two: "Bar")
|
||||
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account", additional_param_one: "Foo", additional_param_two: "Bar")
|
||||
|
||||
expect(form).to have_received(:submit).with(
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "email@test.com",
|
||||
company: "My Account",
|
||||
additional_param_one: "Foo",
|
||||
@@ -42,7 +46,7 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
|
||||
allow(Hubspot::Form).to receive(:new).and_return(form)
|
||||
allow(form).to receive(:submit)
|
||||
|
||||
SubmitHubspotFormJob.perform_now("email@test.com", "My Account")
|
||||
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account")
|
||||
|
||||
expect(form).not_to have_received(:submit)
|
||||
end
|
||||
|
||||
36
spec/jobs/submit_hubspot_task_request_form_job_spec.rb
Normal file
36
spec/jobs/submit_hubspot_task_request_form_job_spec.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SubmitHubspotTaskRequestFormJob, type: :job do
|
||||
describe '#perform_now' do
|
||||
before do
|
||||
ENV["HUBSPOT_TASK_REQUEST_FORM_GUID"] = "hubspot_task_request_form_guid"
|
||||
end
|
||||
|
||||
it 'submits to the Hubspot API with the right params' do
|
||||
form = double(:form)
|
||||
allow(Hubspot::Form).to receive(:new).and_return(form)
|
||||
allow(form).to receive(:submit).and_return(true)
|
||||
|
||||
SubmitHubspotTaskRequestFormJob.perform_now("email@test.com", "https://example.com/admin/task_requests/1")
|
||||
|
||||
expect(Hubspot::Form).to have_received(:new).with("guid" => "hubspot_task_request_form_guid")
|
||||
expect(form).to have_received(:submit).with(
|
||||
email: "email@test.com",
|
||||
taskme_url: "https://example.com/admin/task_requests/1"
|
||||
)
|
||||
end
|
||||
|
||||
context 'when HUBSPOT_TASK_REQUEST_FORM_GUID is not available' do
|
||||
it 'does not submit to the API' do
|
||||
ENV["HUBSPOT_TASK_REQUEST_FORM_GUID"] = nil
|
||||
form = double(:form)
|
||||
allow(Hubspot::Form).to receive(:new).and_return(form)
|
||||
allow(form).to receive(:submit)
|
||||
|
||||
SubmitHubspotTaskRequestFormJob.perform_now("email@test.com", "https://example.com/admin/task_requests/1")
|
||||
|
||||
expect(form).not_to have_received(:submit)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user