2020-04-30 14:50:26 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe ConversationMailbox, type: :mailbox do
|
|
|
|
include ActionMailbox::TestHelper
|
|
|
|
|
|
|
|
describe 'add mail as reply in a conversation' do
|
|
|
|
let(:agent) { create(:user, email: 'agent1@example.com') }
|
|
|
|
let(:reply_mail) { create_inbound_email_from_fixture('reply.eml') }
|
2020-06-09 18:24:35 +00:00
|
|
|
let(:conversation) { create(:conversation, assignee: agent, inbox: create(:inbox, greeting_enabled: false)) }
|
2020-04-30 14:50:26 +00:00
|
|
|
let(:described_subject) { described_class.receive reply_mail }
|
2020-05-22 12:37:06 +00:00
|
|
|
let(:serialized_attributes) { %w[text_content html_content number_of_attachments subject date to from in_reply_to cc bcc message_id] }
|
2020-04-30 14:50:26 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
# this UUID is hardcoded in the reply.eml, that's why we are updating this
|
|
|
|
conversation.uuid = '6bdc3f4d-0bec-4515-a284-5d916fdde489'
|
|
|
|
conversation.save
|
|
|
|
|
|
|
|
described_subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'add the mail content as new message on the conversation' do
|
2020-05-22 12:37:06 +00:00
|
|
|
expect(conversation.messages.last.content).to eq("Let's talk about these images:")
|
2020-04-30 14:50:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'add the attachments' do
|
|
|
|
expect(conversation.messages.last.attachments.count).to eq(2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'have proper content_attributes with details of email' do
|
|
|
|
expect(conversation.messages.last.content_attributes[:email].keys).to eq(serialized_attributes)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'set proper content_type' do
|
|
|
|
expect(conversation.messages.last.content_type).to eq('incoming_email')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|