fix: Save content_type, multipart information to email message model (#2774)

This commit is contained in:
Pranav Raj S
2021-08-09 18:04:34 +05:30
committed by GitHub
parent 462214aced
commit bdc4ecffc1
5 changed files with 40 additions and 14 deletions

View File

@@ -9,7 +9,9 @@ RSpec.describe ReplyMailbox, type: :mailbox do
let(:reply_mail) { create_inbound_email_from_fixture('reply.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 }
let(:serialized_attributes) { %w[text_content html_content number_of_attachments subject date to from in_reply_to cc bcc message_id] }
let(:serialized_attributes) do
%w[bcc cc content_type date from html_content in_reply_to message_id multipart number_of_attachments subject text_content to]
end
before do
# this UUID is hardcoded in the reply.eml, that's why we are updating this

View File

@@ -8,7 +8,10 @@ RSpec.describe SupportMailbox, type: :mailbox do
let!(:channel_email) { create(:channel_email, account: account) }
let(:support_mail) { create_inbound_email_from_fixture('support.eml') }
let(:described_subject) { described_class.receive support_mail }
let(:serialized_attributes) { %w[text_content html_content number_of_attachments subject date to from in_reply_to cc bcc message_id] }
let(:serialized_attributes) do
%w[bcc cc content_type date from html_content in_reply_to message_id multipart number_of_attachments subject
text_content to]
end
let(:conversation) { Conversation.where(inbox_id: channel_email.inbox).last }
before do

View File

@@ -32,12 +32,25 @@ RSpec.describe MailPresenter do
it 'give the serialized data of the email to be stored in the message' do
data = decorated_mail.serialized_data
expect(data.keys).to eq([
:text_content, :html_content, :number_of_attachments, :subject, :date, :to,
:from, :in_reply_to, :cc, :bcc, :message_id
:bcc,
:cc,
:content_type,
:date,
:from,
:html_content,
:in_reply_to,
:message_id,
:multipart,
:number_of_attachments,
:subject,
:text_content,
:to
])
expect(data[:subject]).to eq(decorated_mail.subject)
expect(data[:content_type]).to include('multipart/alternative')
expect(data[:date].to_s).to eq('2020-04-20T04:20:20-04:00')
expect(data[:message_id]).to eq(mail.message_id)
expect(data[:multipart]).to eq(true)
expect(data[:subject]).to eq(decorated_mail.subject)
end
end
end