fix(contact): use user email when no email was specified
This commit is contained in:
parent
45d5e79e55
commit
3469527637
2 changed files with 13 additions and 2 deletions
|
@ -29,7 +29,7 @@ class HelpscoutCreateConversationJob < ApplicationJob
|
|||
|
||||
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
|
||||
|
|
|
@ -8,7 +8,8 @@ RSpec.describe HelpscoutCreateConversationJob, type: :job do
|
|||
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
|
||||
|
@ -82,5 +83,15 @@ RSpec.describe HelpscoutCreateConversationJob, type: :job do
|
|||
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 email from user' do
|
||||
subject
|
||||
expect(api).to have_received(:create_conversation).with(user.email, subject_text, text, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue