mailers: turn revert_to_instruction into a notification email

This commit is contained in:
Pierre de La Morinerie 2019-09-10 11:05:04 +02:00
parent 19e07b0cbf
commit aa1cf6788b
3 changed files with 26 additions and 3 deletions

View file

@ -60,8 +60,13 @@ class DossierMailer < ApplicationMailer
def notify_revert_to_instruction(dossier)
@dossier = dossier
@subject = "Votre dossier nº #{@dossier.id} est en train d'être réexaminé"
@service = dossier.procedure.service
@logo_url = attach_logo(dossier.procedure)
mail(to: dossier.user.email, subject: @subject)
subject = "Votre dossier nº #{@dossier.id} est en train d'être réexaminé"
mail(from: NO_REPLY_EMAIL, to: dossier.user.email, subject: subject) do |format|
format.html { render layout: 'mailers/notifications_layout' }
end
end
end

View file

@ -1,3 +1,6 @@
- content_for :procedure_logo do
= render 'layouts/mailers/logo', url: @logo_url
%p
Bonjour,
@ -13,4 +16,7 @@
email:
= mail_to @dossier.procedure.service.email, @dossier.procedure.service.email
= render partial: "layouts/mailers/signature"
= render 'layouts/mailers/signature'
- content_for :footer do
= render 'layouts/mailers/service_footer', service: @service, dossier: @dossier

View file

@ -67,4 +67,16 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.body).to include("n'a pas pu être supprimé") }
it { expect(subject.body).to include(dossier.procedure.libelle) }
end
describe '.notify_revert_to_instruction' do
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
subject { described_class.notify_revert_to_instruction(dossier) }
it { expect(subject.subject).to include('réexaminé') }
it { expect(subject.body).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier_url(dossier)) }
it_behaves_like 'a dossier notification'
end
end