improve transfer mail for user without account
This commit is contained in:
parent
6b322d61ca
commit
5b31aca888
5 changed files with 32 additions and 2 deletions
|
@ -206,6 +206,8 @@ class DossierMailer < ApplicationMailer
|
|||
def notify_transfer
|
||||
@transfer = params[:dossier_transfer]
|
||||
|
||||
@user = User.find_by(email: @transfer.email)
|
||||
|
||||
configure_defaults_for_email(@transfer.email)
|
||||
|
||||
I18n.with_locale(@transfer.user_locale) do
|
||||
|
|
|
@ -10,7 +10,13 @@
|
|||
= dossier.procedure.libelle
|
||||
|
||||
%p
|
||||
= t('.transfer_text')
|
||||
= link_to t('.transfer_link'), dossiers_url(statut: 'dossiers-transferes')
|
||||
- if @user.present?
|
||||
= t('.transfer_text')
|
||||
%br
|
||||
= link_to t('.transfer_link'), dossiers_url(statut: 'dossiers-transferes')
|
||||
- else
|
||||
= t('.no_user_transfer_text')
|
||||
%br
|
||||
= link_to t('.no_user_transfer_link', app_name: Current.application_name), new_user_registration_url
|
||||
|
||||
= render partial: "layouts/mailers/signature"
|
||||
|
|
|
@ -4,5 +4,7 @@ en:
|
|||
subject: You have a pending transfer request.
|
||||
transfer_text: "Access the transfer request by clicking on the following link:"
|
||||
transfer_link: transfer request
|
||||
no_user_transfer_text: "In order to accept or refuse the request you must have an account:"
|
||||
no_user_transfer_link: Create an account on %{app_name}
|
||||
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"
|
||||
|
|
|
@ -4,5 +4,7 @@ fr:
|
|||
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
|
||||
no_user_transfer_text: "Afin de pouvoir accepter ou refuser la demande vous devez avoir un compte :"
|
||||
no_user_transfer_link: se créer un compte sur %{app_name}
|
||||
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"
|
||||
|
|
|
@ -313,6 +313,7 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
|
||||
describe 'notify_transfer' do
|
||||
let(:user) { create(:user) }
|
||||
let(:user_2) { create(:user) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier_transfer) { create(:dossier_transfer) }
|
||||
let!(:dossier) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) }
|
||||
|
@ -327,6 +328,23 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the user has already an account' do
|
||||
before do
|
||||
dossier_transfer.update!(email: user_2.email)
|
||||
end
|
||||
it 'includes a direct URL to transfers' do
|
||||
expect(subject.body).to include('Accéder à la demande de transfert en cliquant sur le lien suivant :')
|
||||
expect(subject.body).to include(dossiers_url(statut: 'dossiers-transferes', host: ENV.fetch("APP_HOST_LEGACY")))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the user has no account' do
|
||||
it 'includes a URL to create one' do
|
||||
expect(subject.body).to include('Afin de pouvoir accepter ou refuser la demande vous devez avoir un compte :')
|
||||
expect(subject.body).to include(new_user_registration_url)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when recipient has preferred domain' do
|
||||
let(:dossier_transfer) { create(:dossier_transfer, email: create(:user, preferred_domain: :demarches_gouv_fr).email) }
|
||||
it 'includes a link with the preferred domain in the email body' do
|
||||
|
|
Loading…
Reference in a new issue