feat: set first and last name for email
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
module MailboxHelper
|
||||
include ContactHelper
|
||||
|
||||
private
|
||||
|
||||
def create_message
|
||||
@@ -87,11 +89,15 @@ module MailboxHelper
|
||||
end
|
||||
|
||||
def create_contact
|
||||
name_parts = split_first_and_last_name(identify_contact_name)
|
||||
first_name = name_parts[:first_name]
|
||||
last_name = name_parts[:last_name]
|
||||
@contact_inbox = ::ContactInboxWithContactBuilder.new(
|
||||
source_id: processed_mail.original_sender,
|
||||
inbox: @inbox,
|
||||
contact_attributes: {
|
||||
name: identify_contact_name,
|
||||
name: first_name,
|
||||
last_name: last_name,
|
||||
email: processed_mail.original_sender,
|
||||
additional_attributes: {
|
||||
source_id: "email:#{processed_mail.message_id}"
|
||||
|
||||
@@ -89,9 +89,9 @@ RSpec.describe SupportMailbox do
|
||||
end
|
||||
|
||||
it 'create a new contact as the sender of the email' do
|
||||
email_sender = Mail::Address.new(support_mail.mail[:from].value).name
|
||||
expect(conversation.messages.last.sender.email).to eq(support_mail.mail.from.first)
|
||||
expect(conversation.contact.name).to eq(email_sender)
|
||||
expect(conversation.contact.name).to eq('Sony')
|
||||
expect(conversation.contact.last_name).to eq('Mathew')
|
||||
end
|
||||
|
||||
it 'add the mail content as new message on the conversation' do
|
||||
@@ -178,10 +178,9 @@ RSpec.describe SupportMailbox do
|
||||
|
||||
it 'create new contact with original sender' do
|
||||
described_subject
|
||||
email_sender = Mail::Address.new(group_sender_support_mail.mail[:from].value).name
|
||||
|
||||
expect(conversation.contact.email).to eq(group_sender_support_mail.mail['X-Original-Sender'].value)
|
||||
expect(conversation.contact.name).to eq(email_sender)
|
||||
expect(conversation.contact.name).to eq('ACME')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user