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