diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 8ab0d1d..a5e17b5 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -17,7 +17,7 @@ class AccountsController < ApplicationController if sign_in(user) TrackAnalyticsJob.perform_later(user, user.primary_account, :track_guest_sign_up, user_agent: request.user_agent, user_ip: request.remote_ip) - SubmitHubspotFormJob.perform_later(user.email, account.name, i_m_interested_in: user.interested_product_name) + SubmitHubspotFormJob.perform_later(user.first_name, user.last_name, user.email, account.name, i_m_interested_in: user.interested_product_name) redirect_to signed_in_root_path else redirect_to new_session_path, alert: t(".notice") diff --git a/app/jobs/submit_hubspot_form_job.rb b/app/jobs/submit_hubspot_form_job.rb index d83ba19..2bdcd43 100644 --- a/app/jobs/submit_hubspot_form_job.rb +++ b/app/jobs/submit_hubspot_form_job.rb @@ -1,12 +1,14 @@ class SubmitHubspotFormJob < ApplicationJob queue_as :default - def perform(email, company_name, additional_params = {}) + def perform(first_name, last_name, email, company_name, additional_params = {}) hubspot_form_guid = ENV["HUBSPOT_FORM_GUID"] return unless hubspot_form_guid.present? submission_params = { - email: email, + first_name: first_name, + last_name: last_name, + email: email, company: company_name }.merge(additional_params) diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index f85dbc9..f7ae8d9 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -57,6 +57,8 @@ RSpec.describe AccountsController, type: :controller do expect { post :create, params: params }.to have_enqueued_job(SubmitHubspotFormJob).with( + "John", + "Doe", "test_user+1@test.com", "Test Dev account", i_m_interested_in: "DirectME" diff --git a/spec/jobs/submit_hubspot_form_job_spec.rb b/spec/jobs/submit_hubspot_form_job_spec.rb index 6da3747..80e701c 100644 --- a/spec/jobs/submit_hubspot_form_job_spec.rb +++ b/spec/jobs/submit_hubspot_form_job_spec.rb @@ -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