feat: Add specs for reply-to changes (#3959)
This commit is contained in:
@@ -7,6 +7,7 @@ RSpec.describe ReplyMailbox, type: :mailbox do
|
||||
let(:account) { create(:account) }
|
||||
let(:agent) { create(:user, email: 'agent1@example.com', account: account) }
|
||||
let(:reply_mail) { create_inbound_email_from_fixture('reply.eml') }
|
||||
let(:reply_to_mail) { create_inbound_email_from_fixture('reply_to.eml') }
|
||||
let(:mail_with_quote) { create_inbound_email_from_fixture('mail_with_quote.eml') }
|
||||
let(:conversation) { create(:conversation, assignee: agent, inbox: create(:inbox, account: account, greeting_enabled: false), account: account) }
|
||||
let(:described_subject) { described_class.receive reply_mail }
|
||||
@@ -59,12 +60,37 @@ RSpec.describe ReplyMailbox, type: :mailbox do
|
||||
reply_mail_without_uuid.mail['In-Reply-To'] = '<conversation/6bdc3f4d-0bec-4515-a284-5d916fdde489/messages/123@test.com>'
|
||||
end
|
||||
|
||||
it 'find channel with reply to mail' do
|
||||
it 'find channel with in-reply-to mail' do
|
||||
described_subject
|
||||
expect(conversation_1.messages.last.content).to eq("Let's talk about these images:")
|
||||
end
|
||||
end
|
||||
|
||||
context 'with reply_to email address present' do
|
||||
let(:email_channel) { create(:channel_email, email: 'test@example.com', account: account) }
|
||||
let(:conversation_1) do
|
||||
create(
|
||||
:conversation,
|
||||
assignee: agent,
|
||||
inbox: email_channel.inbox,
|
||||
account: account,
|
||||
additional_attributes: { mail_subject: "Discussion: Let's debate these attachments" }
|
||||
)
|
||||
end
|
||||
|
||||
before do
|
||||
conversation_1.update!(uuid: '6bdc3f4d-0bec-4515-a284-5d916fdde489')
|
||||
end
|
||||
|
||||
it 'prefer reply-to over from address' do
|
||||
described_class.receive reply_to_mail
|
||||
expect(conversation_1.messages.last.content).to eq("Let's talk about these images:")
|
||||
|
||||
email = conversation_1.messages.last.content_attributes['email']
|
||||
expect(reply_to_mail.mail['Reply-To'].value).to include(email['from'][0])
|
||||
end
|
||||
end
|
||||
|
||||
context 'without email to address' do
|
||||
let(:forwarder_email) { create_inbound_email_from_fixture('forwarder_email.eml') }
|
||||
let(:in_reply_to_email) { create_inbound_email_from_fixture('in_reply_to.eml') }
|
||||
|
||||
@@ -179,5 +179,24 @@ RSpec.describe SupportMailbox, type: :mailbox do
|
||||
expect(conversation.messages.last.content_attributes['email']['subject']).to eq('Get Paid to post an article')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Sender with reply_to email address' do
|
||||
let(:reply_to_mail) { create_inbound_email_from_fixture('reply_to.eml') }
|
||||
let(:email_channel) { create(:channel_email, email: 'test@example.com', account: account) }
|
||||
|
||||
it 'prefer reply-to over from address' do
|
||||
email_channel
|
||||
described_class.receive reply_to_mail
|
||||
|
||||
conversation_1 = Conversation.last
|
||||
email = conversation_1.messages.last.content_attributes['email']
|
||||
|
||||
expect(reply_to_mail.mail['From'].value).to be_present
|
||||
expect(conversation_1.messages.last.content).to eq("Let's talk about these images:")
|
||||
expect(reply_to_mail.mail['Reply-To'].value).to include(email['from'][0])
|
||||
expect(reply_to_mail.mail['Reply-To'].value).to include(conversation_1.contact.email)
|
||||
expect(reply_to_mail.mail['From'].value).not_to include(conversation_1.contact.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user