Feature: Conversation creation email notifications (#576)

* Clean up the mailers

* Disable assignment mailer if setting is turned off

* Email notifications on conversation create

* Specs
This commit is contained in:
Sojan Jose
2020-03-01 19:06:13 +05:30
committed by GitHub
parent d6237dfc59
commit cda65ea339
17 changed files with 160 additions and 31 deletions

View File

@@ -1,17 +1,17 @@
require 'rails_helper'
Sidekiq::Testing.fake!
RSpec.describe ConversationEmailWorker, type: :worker do
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) }
describe 'testing ConversationEmailWorker' do
describe 'testing ConversationSummaryEmailWorker' do
before do
conversation.save!
allow(Conversation).to receive(:find).and_return(conversation)
mailer = double
allow(ConversationMailer).to receive(:new_message).and_return(mailer)
allow(ConversationReplyMailer).to receive(:reply_with_summary).and_return(mailer)
allow(mailer).to receive(:deliver_later).and_return(true)
end
@@ -28,9 +28,9 @@ RSpec.describe ConversationEmailWorker, type: :worker do
end
context 'with actions performed by the worker' do
it 'calls ConversationMailer' do
it 'calls ConversationSummaryMailer' do
described_class.new.perform(1, Time.zone.now)
expect(ConversationMailer).to have_received(:new_message)
expect(ConversationReplyMailer).to have_received(:reply_with_summary)
end
end
end