refactor(avis): rename revive by remind

This commit is contained in:
Eric Leroy-Terquem 2023-01-26 16:19:06 +01:00
parent 2475bb1098
commit b306dea5cf
7 changed files with 12 additions and 12 deletions

View file

@ -14,7 +14,7 @@ module Instructeurs
end
end
def revive
def remind
avis = Avis.find(params[:id])
if avis.remind_by!(current_instructeur)
AvisMailer.avis_invitation(avis).deliver_later

View file

@ -84,8 +84,8 @@ class Avis < ApplicationRecord
revoked_at.present?
end
def revivable_by?(reviver)
revokable_by?(reviver)
def remindable_by?(reminder)
revokable_by?(reminder)
end
def revokable_by?(revocator)
@ -103,7 +103,7 @@ class Avis < ApplicationRecord
end
def remind_by!(revocator)
return false if !revivable_by?(revocator) || answer.present?
update!(revived_at: Time.zone.now)
return false if !remindable_by?(revocator) || answer.present?
update!(reminded_at: Time.zone.now)
end
end

View file

@ -36,7 +36,7 @@
%span.fr-text--xs.fr-text-mention--grey
= t('en_attente', scope: 'views.shared.avis')
|
%span= link_to(t('revive', scope: 'helpers.label'), revive_instructeur_avis_path(avis.procedure, avis), data: { confirm: t('revive', scope: 'helpers.confirmation', email: avis.expert.email) })
%span= link_to(t('remind', scope: 'helpers.label'), remind_instructeur_avis_path(avis.procedure, avis), data: { confirm: t('remind', scope: 'helpers.confirmation', email: avis.expert.email) })
- if avis.revokable_by?(current_instructeur)
|
= link_to(t('revoke', scope: 'helpers.label'), revoquer_instructeur_avis_path(avis.procedure, avis), data: { confirm: t('revoke', scope: 'helpers.confirmation', email: avis.expert.email) }, method: :patch)

View file

@ -13,9 +13,9 @@ fr:
one: Inviter aussi lexpert sur le dossier lié n° %{ids}
other: Inviter aussi lexpert sur les dossiers liés n° %{ids}
revoke: Révoquer la demande davis
revive: Relancer lexpert
remind: Relancer lexpert
hint:
confidentiel: "Cet avis nest pas affiché avec les autres experts consultés"
confirmation:
revoke: "Souhaitez-vous révoquer la demande davis à %{email} ?"
revive: "Souhaitez-vous relancer %{email} ?"
remind: "Souhaitez-vous relancer %{email} ?"

View file

@ -7,7 +7,7 @@ en:
avis:
demande_envoyee_le: "Feedback send at %{date}"
demande_revoquee_le: "Feedback revoked at %{date}"
relance_effectuee_le: "Revival sent at %{date}"
relance_effectuee_le: "Reminder sent at %{date}"
reponse_donnee_le: "Response sent at %{date}"
en_attente: "Waiting for response"
france_connect_login:

View file

@ -393,7 +393,7 @@ Rails.application.routes.draw do
get '', action: 'procedure', on: :collection, as: :procedure
member do
patch 'revoquer'
get 'revive'
get 'remind'
end
end

View file

@ -24,13 +24,13 @@ describe Instructeurs::AvisController, type: :controller do
end
end
describe 'revive' do
describe 'remind' do
before do
allow(AvisMailer).to receive(:avis_invitation).and_return(double(deliver_later: nil))
end
it 'sends a reminder to the expert' do
get :revive, params: { procedure_id: procedure.id, id: avis.id }
get :remind, params: { procedure_id: procedure.id, id: avis.id }
expect(AvisMailer).to have_received(:avis_invitation).once.with(avis)
expect(flash.notice).to eq("Un mail de relance a été envoyé à #{avis.expert.email}")
expect(avis.reload.reminded_at).to be_present