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:
Colin Darie 2024-08-01 15:24:51 +00:00 committed by GitHub
commit 3501208191
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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