From 1a123a4f566e3b39563fee5c0f66a80f47a27693 Mon Sep 17 00:00:00 2001 From: sony-mathew Date: Sun, 10 May 2020 14:03:11 +0530 Subject: [PATCH] Spec for private messages not to be included in mails (#837) --- spec/mailers/conversation_reply_mailer_spec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/mailers/conversation_reply_mailer_spec.rb b/spec/mailers/conversation_reply_mailer_spec.rb index f6d61a577..21ec9addb 100644 --- a/spec/mailers/conversation_reply_mailer_spec.rb +++ b/spec/mailers/conversation_reply_mailer_spec.rb @@ -12,15 +12,31 @@ RSpec.describe ConversationReplyMailer, type: :mailer do allow(class_instance).to receive(:smtp_config_set_or_development?).and_return(true) end - context 'when custom domain and email is not enabled' do + context 'with all mails' do let(:conversation) { create(:conversation, assignee: agent) } let(:message) { create(:message, conversation: conversation) } + let(:private_message) { create(:message, content: 'This is a private message', private: true, conversation: conversation) } let(:mail) { described_class.reply_with_summary(message.conversation, Time.zone.now).deliver_now } it 'renders the subject' do expect(mail.subject).to eq("[##{message.conversation.display_id}] #{message.content.truncate(30)}") 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) + expect(mail.body.decoded).to include(message.content) + end + end + + context 'when custom domain and email is not 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 } + it 'renders the receiver email' do expect(mail.to).to eq([message&.conversation&.contact&.email]) end