11b4b4ea3f
* Chore: Parse quoted text in incoming emails (#883) * Parsed the quoted text and replies in incoming emails and store them separately * Did this parsing for plain text and html part of emails * In the chat window, we will only show the parsed reply alone * Conversation mailbox test fixes (#883)
36 lines
1.4 KiB
Ruby
36 lines
1.4 KiB
Ruby
require 'rails_helper'
|
|
RSpec.describe MailPresenter do
|
|
include ActionMailbox::TestHelper
|
|
|
|
describe 'parsed mail decorator' do
|
|
let(:mail) { create_inbound_email_from_fixture('welcome.eml').mail }
|
|
let(:decorated_mail) { described_class.new(mail) }
|
|
|
|
it 'give utf8 encoded content' do
|
|
expect(decorated_mail.subject).to eq("Discussion: Let's debate these attachments")
|
|
expect(decorated_mail.text_content[:full]).to eq("Let's talk about these images:\r\n\r\n")
|
|
end
|
|
|
|
it 'give decoded blob attachments' do
|
|
decorated_mail.attachments.each do |attachment|
|
|
expect(attachment.keys).to eq([:original, :blob])
|
|
expect(attachment[:blob].class.name).to eq('ActiveStorage::Blob')
|
|
end
|
|
end
|
|
|
|
it 'give number of attachments of the mail' do
|
|
expect(decorated_mail.number_of_attachments).to eq(2)
|
|
end
|
|
|
|
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
|
|
])
|
|
expect(data[:subject]).to eq(decorated_mail.subject)
|
|
expect(data[:date].to_s).to eq('2020-04-20T04:20:20-04:00')
|
|
expect(data[:message_id]).to eq(mail.message_id)
|
|
end
|
|
end
|
|
end
|