Merge pull request #10672 from colinux/fix-contact-with-user
ETQ utilisateur, fix l'envoi à HS du form de contact quand on est déjà connecté
This commit is contained in:
commit
3501208191
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