fix: Fetch email address to create contact (#4952)

Get the email address from the email content in the correct format.

Fixes: chatwoot/product#454
This commit is contained in:
Tejaswini Chile
2022-07-02 17:40:28 +05:30
committed by GitHub
parent ac7ebe516a
commit 97bf5d0c6a
3 changed files with 649 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ RSpec.describe SupportMailbox, type: :mailbox do
let(:agent) { create(:user, email: 'agent1@example.com', account: account) }
let!(:channel_email) { create(:channel_email, account: account) }
let(:support_mail) { create_inbound_email_from_fixture('support.eml') }
let(:support_in_reply_to_mail) { create_inbound_email_from_fixture('support_in_reply_to.eml') }
let(:described_subject) { described_class.receive support_mail }
let(:serialized_attributes) do
%w[bcc cc content_type date from html_content in_reply_to message_id multipart number_of_attachments subject
@@ -34,6 +35,17 @@ RSpec.describe SupportMailbox, type: :mailbox do
channel_email.save
end
describe 'covers email address format' do
before do
described_class.receive support_in_reply_to_mail
end
it 'creates contact with proper email address' do
expect(support_in_reply_to_mail.mail['reply_to'].try(:value)).to eq('Sony Mathew <sony@chatwoot.com>')
expect(conversation.contact.email).to eq('sony@chatwoot.com')
end
end
describe 'covers basic ticket creation' do
before do
described_subject