Notification Mailer: use send_notification for all the mails
This commit is contained in:
parent
70b2020656
commit
6c560e65eb
4 changed files with 22 additions and 43 deletions
|
@ -95,40 +95,46 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
|
|
||||||
NotificationMailer.send_notification(dossier, dossier.procedure.initiated_mail).deliver_now!
|
NotificationMailer.send_notification(dossier, dossier.procedure.initiated_mail).deliver_now!
|
||||||
|
|
||||||
redirect_to backoffice_dossier_path(id: @facade.dossier.id)
|
redirect_to backoffice_dossier_path(id: dossier.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def refuse
|
def refuse
|
||||||
create_dossier_facade params[:dossier_id]
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
@facade.dossier.next_step! 'gestionnaire', 'refuse'
|
dossier = @facade.dossier
|
||||||
|
|
||||||
|
dossier.next_step! 'gestionnaire', 'refuse'
|
||||||
flash.notice = 'Dossier considéré comme refusé.'
|
flash.notice = 'Dossier considéré comme refusé.'
|
||||||
|
|
||||||
NotificationMailer.dossier_refused(@facade.dossier).deliver_now!
|
NotificationMailer.send_notification(dossier, dossier.procedure.refused_mail).deliver_now!
|
||||||
|
|
||||||
redirect_to backoffice_dossier_path(id: @facade.dossier.id)
|
redirect_to backoffice_dossier_path(id: dossier.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def without_continuation
|
def without_continuation
|
||||||
create_dossier_facade params[:dossier_id]
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
@facade.dossier.next_step! 'gestionnaire', 'without_continuation'
|
dossier = @facade.dossier
|
||||||
|
|
||||||
|
dossier.next_step! 'gestionnaire', 'without_continuation'
|
||||||
flash.notice = 'Dossier considéré comme sans suite.'
|
flash.notice = 'Dossier considéré comme sans suite.'
|
||||||
|
|
||||||
NotificationMailer.dossier_without_continuation(@facade.dossier).deliver_now!
|
NotificationMailer.send_notification(dossier, dossier.procedure.without_continuation_mail).deliver_now!
|
||||||
|
|
||||||
redirect_to backoffice_dossier_path(id: @facade.dossier.id)
|
redirect_to backoffice_dossier_path(id: dossier.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
create_dossier_facade params[:dossier_id]
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
@facade.dossier.next_step! 'gestionnaire', 'close'
|
dossier = @facade.dossier
|
||||||
|
|
||||||
|
dossier.next_step! 'gestionnaire', 'close'
|
||||||
flash.notice = 'Dossier traité avec succès.'
|
flash.notice = 'Dossier traité avec succès.'
|
||||||
|
|
||||||
NotificationMailer.dossier_closed(@facade.dossier).deliver_now!
|
NotificationMailer.send_notification(dossier, dossier.procedure.closed_mail).deliver_now!
|
||||||
|
|
||||||
redirect_to backoffice_dossier_path(id: @facade.dossier.id)
|
redirect_to backoffice_dossier_path(id: dossier.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def follow
|
def follow
|
||||||
|
|
|
@ -15,22 +15,6 @@ class NotificationMailer < ApplicationMailer
|
||||||
send_mail dossier, "Nouveau message pour votre dossier TPS N°#{dossier.id}"
|
send_mail dossier, "Nouveau message pour votre dossier TPS N°#{dossier.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_submitted dossier
|
|
||||||
send_mail dossier, "Votre dossier TPS N°#{dossier.id} a été déposé"
|
|
||||||
end
|
|
||||||
|
|
||||||
def dossier_without_continuation dossier
|
|
||||||
send_mail dossier, "Votre dossier TPS N°#{dossier.id} a été classé sans suite"
|
|
||||||
end
|
|
||||||
|
|
||||||
def dossier_refused dossier
|
|
||||||
send_mail dossier, "Votre dossier TPS N°#{dossier.id} a été refusé"
|
|
||||||
end
|
|
||||||
|
|
||||||
def dossier_closed dossier
|
|
||||||
send_mail dossier, "Votre dossier TPS N°#{dossier.id} a été accepté"
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def vars_mailer dossier
|
def vars_mailer dossier
|
||||||
|
|
|
@ -262,7 +262,8 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Notification email is sent' do
|
it 'Notification email is sent' do
|
||||||
expect(NotificationMailer).to receive(:dossier_refused).and_return(NotificationMailer)
|
expect(NotificationMailer).to receive(:send_notification)
|
||||||
|
.with(dossier, kind_of(RefusedMail)).and_return(NotificationMailer)
|
||||||
expect(NotificationMailer).to receive(:deliver_now!)
|
expect(NotificationMailer).to receive(:deliver_now!)
|
||||||
|
|
||||||
subject
|
subject
|
||||||
|
@ -287,7 +288,8 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Notification email is sent' do
|
it 'Notification email is sent' do
|
||||||
expect(NotificationMailer).to receive(:dossier_without_continuation).and_return(NotificationMailer)
|
expect(NotificationMailer).to receive(:send_notification)
|
||||||
|
.with(dossier, kind_of(WithoutContinuationMail)).and_return(NotificationMailer)
|
||||||
expect(NotificationMailer).to receive(:deliver_now!)
|
expect(NotificationMailer).to receive(:deliver_now!)
|
||||||
|
|
||||||
subject
|
subject
|
||||||
|
@ -311,7 +313,8 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Notification email is sent' do
|
it 'Notification email is sent' do
|
||||||
expect(NotificationMailer).to receive(:dossier_closed).and_return(NotificationMailer)
|
expect(NotificationMailer).to receive(:send_notification)
|
||||||
|
.with(dossier, kind_of(ClosedMail)).and_return(NotificationMailer)
|
||||||
expect(NotificationMailer).to receive(:deliver_now!)
|
expect(NotificationMailer).to receive(:deliver_now!)
|
||||||
|
|
||||||
subject
|
subject
|
||||||
|
|
|
@ -21,18 +21,4 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||||
it { expect(subject.body).to include("Pour le consulter, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") }
|
it { expect(subject.body).to include("Pour le consulter, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") }
|
||||||
it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS N°#{dossier.id}") }
|
it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS N°#{dossier.id}") }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".dossier_submitted" do
|
|
||||||
let(:user) { create(:user) }
|
|
||||||
let(:dossier) { create(:dossier, user: user) }
|
|
||||||
|
|
||||||
subject(:subject) { described_class.dossier_submitted(dossier) }
|
|
||||||
|
|
||||||
before { dossier.reload }
|
|
||||||
|
|
||||||
it { expect(subject.body).to match("Nous vous confirmons que votre dossier N°#{dossier.id} a été déposé") }
|
|
||||||
it { expect(subject.body).to match("auprès de #{dossier.procedure.organisation} avec succès") }
|
|
||||||
it { expect(subject.body).to match("ce jour à #{dossier.updated_at}.") }
|
|
||||||
it { expect(subject.subject).to eq("Votre dossier TPS N°#{dossier.id} a été déposé") }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue