Skip to content

Commit

Permalink
fix(contact): use user email when no email was specified
Browse files Browse the repository at this point in the history
  • Loading branch information
colinux committed Aug 1, 2024
1 parent 45d5e79 commit 7064202
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/jobs/helpscout_create_conversation_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def perform(contact_form)

def create_conversation
response = api.create_conversation(
contact_form.email,
contact_form.email.presence || contact_form.user.email,
contact_form.subject,
contact_form.text,
safe_blob
Expand Down
13 changes: 12 additions & 1 deletion spec/jobs/helpscout_create_conversation_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
let(:tags) { ["first tag"] }
let(:question_type) { "lost" }
let(:phone) { nil }
let(:contact_form) { create(:contact_form, email:, subject: subject_text, text:, tags:, phone:, question_type:) }
let(:user) { nil }
let(:contact_form) { create(:contact_form, email:, user:, subject: subject_text, text:, tags:, phone:, question_type:) }

describe '#perform' do
before do
Expand Down Expand Up @@ -82,5 +83,15 @@
expect(api).to have_received(:add_phone_number).with(email, phone)
end
end

context 'attached to an user' do
let(:email) { nil }
let(:user) { users(:default_user) }

it 'associates the phone number' do
subject
expect(api).to have_received(:create_conversation).with(user.email, subject_text, text, nil)
end
end
end
end

0 comments on commit 7064202

Please sign in to comment.