Right now as part of conversation continuity, we are using the ConversationReplyMailer which sends a summary of messages including the incoming messages when an agent replies. Ideally, we want to send only the reply of that agent and not a summary when Conversation continuity is enabled. Added the functionality to send the reply email without summary. Added required unit tests to cover the changes. ref: #1048
This commit is contained in:
@@ -5,6 +5,7 @@ RSpec.describe ConversationReplyEmailWorker, type: :worker do
|
||||
let(:perform_at) { (Time.zone.today + 6.hours).to_datetime }
|
||||
let(:scheduled_job) { described_class.perform_at(perform_at, 1, Time.zone.now) }
|
||||
let(:conversation) { build(:conversation, display_id: nil) }
|
||||
let(:message) { build(:message, conversation: conversation, content_type: 'incoming_email', inbox: conversation.inbox) }
|
||||
|
||||
describe 'testing ConversationSummaryEmailWorker' do
|
||||
before do
|
||||
@@ -12,6 +13,7 @@ RSpec.describe ConversationReplyEmailWorker, type: :worker do
|
||||
allow(Conversation).to receive(:find).and_return(conversation)
|
||||
mailer = double
|
||||
allow(ConversationReplyMailer).to receive(:reply_with_summary).and_return(mailer)
|
||||
allow(ConversationReplyMailer).to receive(:reply_without_summary).and_return(mailer)
|
||||
allow(mailer).to receive(:deliver_later).and_return(true)
|
||||
end
|
||||
|
||||
@@ -28,10 +30,16 @@ RSpec.describe ConversationReplyEmailWorker, type: :worker do
|
||||
end
|
||||
|
||||
context 'with actions performed by the worker' do
|
||||
it 'calls ConversationSummaryMailer' do
|
||||
it 'calls ConversationSummaryMailer#reply_with_summary when last incoming message was not email' do
|
||||
described_class.new.perform(1, Time.zone.now)
|
||||
expect(ConversationReplyMailer).to have_received(:reply_with_summary)
|
||||
end
|
||||
|
||||
it 'calls ConversationSummaryMailer#reply_without_summary when last incoming message was from email' do
|
||||
message.save
|
||||
described_class.new.perform(1, Time.zone.now)
|
||||
expect(ConversationReplyMailer).to have_received(:reply_without_summary)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user