Merge pull request #9882 from demarches-simplifiees/add-dossier-reference-in-transfer-email

Je veux que le numéro du dossier apparaisse dans l'email de demande de transfert
This commit is contained in:
Lisa Durand 2024-01-15 15:39:09 +00:00 committed by GitHub
commit d9b75ce0a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 13 deletions

View file

@ -164,7 +164,7 @@ class DossierMailer < ApplicationMailer
def notify_transfer(transfer)
I18n.with_locale(transfer.user_locale) do
@subject = default_i18n_subject(count: transfer.dossiers.size)
@subject = default_i18n_subject()
@transfer = transfer
mail(to: transfer.email, subject: @subject)

View file

@ -58,6 +58,18 @@ class DossierTransfer < ApplicationRecord
end
end
def sender
if from_support?
I18n.t("views.users.dossiers.transfers.sender_from_support")
else
sender_email
end
end
def sender_email
dossiers.last.user.email
end
private
def send_notification

View file

@ -1,9 +1,16 @@
- content_for(:title, "#{@subject}")
%p= t(:hello, scope: [:views, :shared, :greetings])
%p
= t('.body', count: @transfer.dossiers.size)
- if @transfer.dossiers.size > 1
= t('.transfert_multiple', sender: @transfer.sender, count: @transfer.dossiers.size)
- else
- dossier = @transfer.dossiers.last
= t('.transfert_simple', sender: @transfer.sender, dossier_id: dossier.id)
%span{ :style => "font-weight: bold;" }
= dossier.procedure.libelle
%p
= t('.transfer_text')
= link_to t('.transfer_link'), dossiers_url(statut: 'dossiers-transferes')
= render partial: "layouts/mailers/signature"

View file

@ -490,8 +490,9 @@ en:
deleted: Deleted at %{date}
deleted_badge: Deleted
transfers:
sender_from_support: Technical support
sender_demande_en_cours: "A transfer request is pending on file Nº %{id} to %{email}"
sender_demande_en_cours: "A transfer request from technical support is pending on file Nº %{id} to %{email}"
sender_demande_en_cours_from_support: "A transfer request from technical support is pending on file Nº %{id} to %{email}"
receiver_demande_en_cours: "Transfer request on file Nº %{id} sent by %{email}"
receiver_demande_en_cours_from_support: "Transfer request from technical support on file Nº %{id} of %{email}"
revoke: Revoke this request

View file

@ -504,6 +504,7 @@ fr:
actions: "Actions"
other_actions: "Autres actions"
transfers:
sender_from_support: Le support technique
sender_demande_en_cours: "Une demande de transfert est en cours sur le dossier Nº %{id} pour %{email}"
sender_demande_en_cours_from_support: "Une demande de transfert par le support technique est en cours sur le dossier Nº %{id} pour %{email}"
receiver_demande_en_cours: "Demande de transfert pour le dossier Nº %{id} envoyé par %{email}"

View file

@ -0,0 +1,8 @@
en:
dossier_mailer:
notify_transfer:
subject: You have a pending transfer request.
transfer_text: "Access the transfer request by clicking on the following link:"
transfer_link: transfer request
transfert_multiple: "%{sender} sends you a transfer request for %{count} files."
transfert_simple: "%{sender} sends you a transfer request for file no. %{dossier_id} on the procedure"

View file

@ -1,12 +1,8 @@
fr:
dossier_mailer:
notify_transfer:
subject:
one: Une demande de transfert de dossier vous est adressée
other: Une demande de transfert de dossiers vous est adressée
subject: Vous avez une demande de transfert en attente.
transfer_text: "Accéder à la demande de transfert en cliquant sur le lien suivant :"
transfer_link: demande de transfert
body:
one: |
Accéder à la demande de transfert du dossier en cliquant sur le lien suivant :
other: |
Accéder à la demande de transfert de %{count} dossiers en cliquant sur le lien suivant :
transfert_multiple: "%{sender} vous adresse une demande de transfert pour %{count} dossiers."
transfert_simple: "%{sender} vous adresse une demande de transfert pour le dossier n° %{dossier_id} sur la démarche"

View file

@ -265,4 +265,34 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.body).to include("réinitialisé") }
end
end
describe 'notify_transfer' do
let(:user) { create(:user) }
let(:procedure) { create(:procedure) }
let(:dossier_transfer) { create(:dossier_transfer) }
let!(:dossier) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) }
subject { described_class.notify_transfer(dossier_transfer) }
context 'when it is a transfer of one dossier' do
it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") }
it { expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour le dossier n° #{dossier.id} sur la démarche") }
it { expect(subject.body).to include(procedure.libelle.to_s) }
end
context 'when it is a transfer of multiple dossiers' do
let!(:dossier2) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) }
it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") }
it { expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour 2 dossiers.") }
end
context 'when it is a transfer of one dossier from super admin' do
before do
dossier_transfer.update!(from_support: true)
end
it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") }
it { expect(subject.body).to include("Le support technique vous adresse une demande de transfert") }
end
end
end