Merge pull request #10859 from demarches-simplifiees/improve-dossier-transfer-ldu

Améliorer le mail si un usager sans compte DS reçoit un transfert de dossier
This commit is contained in:
Lisa Durand 2024-09-24 13:49:45 +00:00 committed by GitHub
commit e1d9ea2a66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 38 additions and 20 deletions

View file

@ -405,10 +405,6 @@ module Users
@transfer = DossierTransfer.new(dossiers: [dossier])
end
def transferer_all
@transfer = DossierTransfer.new(dossiers: current_user.dossiers)
end
def restore
dossier.restore(current_user)
flash.notice = t('users.dossiers.restore')

View file

@ -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

View file

@ -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', app_name: Current.application_name)
%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"

View file

@ -1,7 +0,0 @@
.container.mt-4
Transferer les #{@transfer.dossiers.size} dossiers de votre compte vers le compte dun autre usager :
= form_for @transfer, url: transfers_path, html: { class: 'form mt-2' } do |f|
= f.label :email, 'Email du compte destinataire'
= f.email_field :email, required: true
= f.submit "Envoyer la demande de transfert", class: 'button primary'

View file

@ -315,7 +315,7 @@ en:
new:
title: 'Confirm your email address'
image_alt: "Email sent"
email_cta_html: "Before filling your file, we have to validate your email address <strong>%{email}</strong>."
email_cta_html: "Before proceeding, we have to validate your email address <strong>%{email}</strong>."
email_guidelines_html: "Open your mailbox and <strong>click on the activation link</strong> within the mail we just sent you."
email_missing: "If you have not received our email (have you checked your spam ?), we can resend it."
resent: 'Resend the confirmation email'

View file

@ -307,7 +307,7 @@ fr:
new:
title: 'Confirmez votre adresse email'
image_alt: "Email envoyé"
email_cta_html: "Avant deffectuer votre démarche, nous avons besoin de vérifier votre adresse électronique <strong>%{email}</strong>."
email_cta_html: "Avant de pouvoir continuer, nous avons besoin de vérifier votre adresse électronique <strong>%{email}</strong>."
email_guidelines_html: "Ouvrez votre boîte email, et <strong>cliquez sur le lien dactivation</strong> dans le message que vous avez reçu."
email_missing: "Si vous navez pas reçu notre message (avez-vous vérifié les indésirables ?), nous pouvons vous le renvoyer."
resent: 'Renvoyer un email de confirmation'

View file

@ -2,7 +2,9 @@ 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
transfer_text: "In order to accept or refuse the request you must log in on %{app_name}:"
transfer_link: Acces 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"

View file

@ -2,7 +2,9 @@ fr:
dossier_mailer:
notify_transfer:
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
transfer_text: "Afin de pouvoir accepter ou refuser la demande vous devez vous connectez sur %{app_name} :"
transfer_link: accéder à la 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"

View file

@ -390,7 +390,6 @@ Rails.application.routes.draw do
end
collection do
get 'transferer', to: 'dossiers#transferer_all'
resources :transfers, only: [:create, :update, :destroy]
end
end

View file

@ -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('Afin de pouvoir accepter ou refuser la demande vous devez vous connectez sur')
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