From 7239657a75130fc19ee58d3d6bd22dc0d7dcc685 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 20 Sep 2021 13:26:57 +0200 Subject: [PATCH] [Fix #6481] a user see its waiting transfers --- app/controllers/users/profil_controller.rb | 1 + app/views/users/profil/show.html.haml | 8 ++++++++ config/locales/views/users/profil/fr.yml | 4 ++++ spec/controllers/users/profil_controller_spec.rb | 12 ++++++++++++ 4 files changed, 25 insertions(+) diff --git a/app/controllers/users/profil_controller.rb b/app/controllers/users/profil_controller.rb index 611f00d4a..b8f6e93a0 100644 --- a/app/controllers/users/profil_controller.rb +++ b/app/controllers/users/profil_controller.rb @@ -5,6 +5,7 @@ module Users if: -> { instructeur_signed_in? } def show + @waiting_transfers = current_user.dossiers.joins(:transfer).group('dossier_transfers.email').count.to_a end def renew_api_token diff --git a/app/views/users/profil/show.html.haml b/app/views/users/profil/show.html.haml index a69ba9e30..092ecf164 100644 --- a/app/views/users/profil/show.html.haml +++ b/app/views/users/profil/show.html.haml @@ -31,6 +31,14 @@ = email_field_tag :next_owner, nil, required: true = submit_tag "Transférer tous mes dossiers", class: 'button primary' + - if @waiting_transfers.any? + .card.warning + .card-title= t('.waiting_transfers') + %ul + - @waiting_transfers.each do |email, nb_dossier| + %li= t('.one_waiting_transfer', email: email, count: nb_dossier) + + - if current_administrateur.present? .card .card-title Jeton d’identification de l’API (token) diff --git a/config/locales/views/users/profil/fr.yml b/config/locales/views/users/profil/fr.yml index daca5067b..30fc1f4f2 100644 --- a/config/locales/views/users/profil/fr.yml +++ b/config/locales/views/users/profil/fr.yml @@ -5,6 +5,10 @@ fr: transfer_title: Transferer tous vos dossiers transfer_explication_html: "

Cette fonctionnalité vous permet de changer le propriétaire de tous vos dossiers. C'est généralement utile lors d'un changement de poste ou si vous souhaitez fusionner plusieurs comptes.

Adresse email du destinataire de tous vos dossiers

" + waiting_transfers: "Transfert en attente :" + one_waiting_transfer: + one: "Le nouveau propriétaire %{email} doit confirmer le transfert d'un dossier en suivant les instructions reçues dans son mail." + other: "Le nouveau propriétaire %{email} doit confirmer le transfert de vos %{count} dossiers en suivant les instructions reçues dans son mail." transfer_all_dossiers: new_transfer: one: "Le transfert d'un dossier à %{email} est en cours" diff --git a/spec/controllers/users/profil_controller_spec.rb b/spec/controllers/users/profil_controller_spec.rb index ee8acd259..313faaf65 100644 --- a/spec/controllers/users/profil_controller_spec.rb +++ b/spec/controllers/users/profil_controller_spec.rb @@ -5,6 +5,18 @@ describe Users::ProfilController, type: :controller do before { sign_in(user) } + describe 'GET #show' do + let(:dossiers) { Array.new(3) { create(:dossier, user: user) } } + let(:next_owner) { 'loulou@lou.com' } + let!(:transfer) { DossierTransfer.initiate(next_owner, dossiers) } + + render_views + + before { post :show } + + it { expect(response.body).to include(I18n.t('users.profil.show.one_waiting_transfer', count: dossiers.count, email: next_owner)) } + end + describe 'POST #renew_api_token' do let(:administrateur) { create(:administrateur) }