Add notify_automatic_deletion_to_administration mailer

This commit is contained in:
Paul Chavard 2020-02-18 17:18:06 +01:00
parent 4e116f06a6
commit 8c77d91e9f
4 changed files with 37 additions and 0 deletions

View file

@ -90,4 +90,11 @@ class DossierMailer < ApplicationMailer
mail(to: user.email, subject: @subject) mail(to: user.email, subject: @subject)
end end
def notify_automatic_deletion_to_administration(user, dossier_hashes)
@subject = default_i18n_subject(count: dossier_hashes.count)
@dossier_hashes = dossier_hashes
mail(to: user.email, subject: @subject)
end
end end

View file

@ -0,0 +1,12 @@
- content_for(:title, "#{@subject}")
%p
Bonjour,
%p= t('.automatic_dossier_deletion', count: @dossier_hashes.count)
%ul
- @dossier_hashes.each do |d|
%li= "n° #{d[:id]} (#{d[:procedure_libelle]})"
= render partial: "layouts/mailers/signature"

View file

@ -0,0 +1,9 @@
fr:
dossier_mailer:
notify_automatic_deletion_to_administration:
subject:
one: "Un dossier a été supprimé automatiquement"
other: "Des dossiers ont été supprimés automatiquement"
automatic_dossier_deletion:
one: "Le délai maximum de conservation du dossier suivant a été atteint, il a donc été supprimé :"
other: "Le délai maximum de conservation des dossiers suivants a été atteint, ils ont donc été supprimés :"

View file

@ -122,4 +122,13 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include("nous nous excusons de la gène occasionnée") } it { expect(subject.body).to include("nous nous excusons de la gène occasionnée") }
end end
describe '.notify_automatic_deletion_to_administration' do
let(:dossier) { create(:dossier) }
subject { described_class.notify_automatic_deletion_to_administration(dossier.user, [dossier.hash_for_deletion_mail]) }
it { expect(subject.subject).to eq("Un dossier a été supprimé automatiquement") }
it { expect(subject.body).to include("#{dossier.id} (#{dossier.procedure.libelle})") }
end
end end