relance un expert
This commit is contained in:
parent
bde8fe2c5d
commit
d9cb5c067f
4 changed files with 31 additions and 0 deletions
|
@ -123,6 +123,18 @@ module Instructeurs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def revive
|
||||||
|
avis = Avis.find(params[:id])
|
||||||
|
if avis.answer.blank?
|
||||||
|
AvisMailer.avis_invitation(avis).deliver_later
|
||||||
|
flash.notice = "Un mail de relance a été envoyé à #{avis.email_to_display}"
|
||||||
|
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||||
|
else
|
||||||
|
flash.alert = "#{avis.email} a déjà donné son avis"
|
||||||
|
redirect_back(fallback_location: avis_instructeur_dossier_path(avis.procedure, avis.dossier))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_avis_and_dossier
|
def set_avis_and_dossier
|
||||||
|
|
|
@ -35,7 +35,10 @@
|
||||||
- else
|
- else
|
||||||
%span.waiting
|
%span.waiting
|
||||||
En attente de réponse
|
En attente de réponse
|
||||||
|
|
|
||||||
|
%span.waiting= link_to("Relancer l'expert", revive_instructeur_avis_path(avis.procedure, avis), data: { confirm: "Souhaitez-vous relancer #{avis.email_to_display} ?"})
|
||||||
- if avis.revokable_by?(current_instructeur)
|
- if avis.revokable_by?(current_instructeur)
|
||||||
|
|
|
||||||
= link_to(t('revoke', scope: 'helpers.label'), revoquer_instructeur_avis_path(avis.procedure, avis), data: { confirm: "Souhaitez-vous révoquer la demande d'avis à #{avis.email_to_display} ?" }, method: :patch)
|
= link_to(t('revoke', scope: 'helpers.label'), revoquer_instructeur_avis_path(avis.procedure, avis), data: { confirm: "Souhaitez-vous révoquer la demande d'avis à #{avis.email_to_display} ?" }, method: :patch)
|
||||||
- if avis.piece_justificative_file.attached?
|
- if avis.piece_justificative_file.attached?
|
||||||
= render partial: 'shared/attachment/show', locals: { attachment: avis.piece_justificative_file.attachment }
|
= render partial: 'shared/attachment/show', locals: { attachment: avis.piece_justificative_file.attachment }
|
||||||
|
|
|
@ -319,6 +319,7 @@ Rails.application.routes.draw do
|
||||||
post 'commentaire' => 'avis#create_commentaire'
|
post 'commentaire' => 'avis#create_commentaire'
|
||||||
post 'avis' => 'avis#create_avis'
|
post 'avis' => 'avis#create_avis'
|
||||||
patch 'revoquer'
|
patch 'revoquer'
|
||||||
|
get 'revive'
|
||||||
get 'bilans_bdf'
|
get 'bilans_bdf'
|
||||||
|
|
||||||
get 'sign_up/email/:email' => 'avis#sign_up', constraints: { email: /.*/ }, as: 'sign_up'
|
get 'sign_up/email/:email' => 'avis#sign_up', constraints: { email: /.*/ }, as: 'sign_up'
|
||||||
|
|
|
@ -282,6 +282,21 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
expect(flash.notice).to eq("#{avis.email} ne peut plus donner son avis sur ce dossier.")
|
expect(flash.notice).to eq("#{avis.email} ne peut plus donner son avis sur ce dossier.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'revive' do
|
||||||
|
let(:avis) { create(:avis, claimant: instructeur, email: 'expert@gouv.fr') }
|
||||||
|
let(:procedure) { avis.procedure }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(AvisMailer).to receive(:avis_invitation).and_return(double(deliver_later: nil))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'revive the expert' do
|
||||||
|
get :revive, 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.email}")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without a instructeur signed in' do
|
context 'without a instructeur signed in' do
|
||||||
|
|
Loading…
Reference in a new issue