-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: ability to send out an email without summary #1048 (#1049)
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
- Loading branch information
1 parent
a8ce9ae
commit d5a6f5e
Showing
6 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/views/mailers/conversation_reply_mailer/reply_without_summary.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% @messages.each do |message| %> | ||
<p> | ||
<% if message.content %> | ||
<%= message.content %> | ||
<% end %> | ||
<% if message.attachments %> | ||
<% message.attachments.each do |attachment| %> | ||
attachment [<a href="<%= attachment.file_url %>" _target="blank">click here to view</a>] | ||
<% end %> | ||
<% end %> | ||
</p> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
require 'rails_helper' | ||
|
||
RSpec.describe ConversationReplyMailer, type: :mailer do | ||
describe 'reply_with_summary' do | ||
describe 'reply' do | ||
let!(:account) { create(:account) } | ||
let!(:agent) { create(:user, email: '[email protected]', account: account) } | ||
let(:class_instance) { described_class.new } | ||
|
@@ -13,7 +13,7 @@ | |
allow(class_instance).to receive(:smtp_config_set_or_development?).and_return(true) | ||
end | ||
|
||
context 'with all mails' do | ||
context 'with summary' do | ||
let(:conversation) { create(:conversation, assignee: agent) } | ||
let(:message) { create(:message, conversation: conversation) } | ||
let(:private_message) { create(:message, content: 'This is a private message', conversation: conversation) } | ||
|
@@ -33,6 +33,35 @@ | |
end | ||
end | ||
|
||
context 'without summary' do | ||
let(:conversation) { create(:conversation, assignee: agent) } | ||
let(:message_1) { create(:message, conversation: conversation) } | ||
let(:message_2) { build(:message, conversation: conversation, message_type: 'outgoing', content: 'Outgoing Message') } | ||
let(:private_message) { create(:message, content: 'This is a private message', conversation: conversation) } | ||
let(:mail) { described_class.reply_without_summary(message_1.conversation, Time.zone.now - 1.minute).deliver_now } | ||
|
||
before do | ||
message_2.save | ||
end | ||
|
||
it 'renders the subject' do | ||
expect(mail.subject).to eq("[##{message_2.conversation.display_id}] New messages on this conversation") | ||
end | ||
|
||
it 'not have private notes' do | ||
# make the message private | ||
private_message.private = true | ||
private_message.save | ||
|
||
expect(mail.body.decoded).not_to include(private_message.content) | ||
end | ||
|
||
it 'onlies have the messages sent by the agent' do | ||
expect(mail.body.decoded).not_to include(message_1.content) | ||
expect(mail.body.decoded).to include(message_2.content) | ||
end | ||
end | ||
|
||
context 'when custom domain and email is not enabled' do | ||
let(:inbox) { create(:inbox, account: account) } | ||
let(:inbox_member) { create(:inbox_member, user: agent, inbox: inbox) } | ||
|
@@ -57,7 +86,7 @@ | |
end | ||
end | ||
|
||
context 'when the cutsom domain emails are enabled' do | ||
context 'when the custom domain emails are enabled' do | ||
let(:conversation) { create(:conversation, assignee: agent) } | ||
let(:message) { create(:message, conversation: conversation) } | ||
let(:mail) { described_class.reply_with_summary(message.conversation, Time.zone.now).deliver_now } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters