2019-08-06 11:02:54 +02:00
|
|
|
describe Instructeurs::AvisController, type: :controller do
|
|
|
|
context 'with a instructeur signed in' do
|
2017-12-22 17:11:56 +01:00
|
|
|
render_views
|
2017-09-06 11:21:29 +02:00
|
|
|
|
2020-07-22 16:57:00 +02:00
|
|
|
let(:now) { Time.zone.parse('01/02/2345') }
|
2021-02-28 22:20:24 +01:00
|
|
|
let(:expert) { create(:expert) }
|
2019-08-06 11:02:54 +02:00
|
|
|
let(:claimant) { create(:instructeur) }
|
2021-03-23 12:25:57 +01:00
|
|
|
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
2019-08-06 11:02:54 +02:00
|
|
|
let(:instructeur) { create(:instructeur) }
|
2021-02-28 22:20:24 +01:00
|
|
|
let(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
2017-12-22 17:11:56 +01:00
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
2021-03-23 12:25:57 +01:00
|
|
|
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
|
|
|
let!(:avis_without_answer) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure) }
|
2017-09-06 11:21:29 +02:00
|
|
|
|
2019-08-07 11:15:16 +02:00
|
|
|
before { sign_in(instructeur.user) }
|
2017-09-06 11:21:29 +02:00
|
|
|
|
2021-02-28 22:20:24 +01:00
|
|
|
describe "#revoker" do
|
2017-12-22 17:11:56 +01:00
|
|
|
before do
|
2021-02-28 22:20:24 +01:00
|
|
|
patch :revoquer, params: { procedure_id: procedure.id, id: avis.id }
|
2019-08-21 09:09:20 +02:00
|
|
|
end
|
2020-07-16 11:14:37 +02:00
|
|
|
|
|
|
|
it "revoke the dossier" do
|
2021-02-28 22:20:24 +01:00
|
|
|
expect(flash.notice).to eq("#{avis.expert.email} ne peut plus donner son avis sur ce dossier.")
|
2020-07-16 11:14:37 +02:00
|
|
|
end
|
|
|
|
end
|
2020-07-20 16:26:16 +02:00
|
|
|
|
|
|
|
describe 'revive' do
|
|
|
|
before do
|
|
|
|
allow(AvisMailer).to receive(:avis_invitation).and_return(double(deliver_later: nil))
|
|
|
|
end
|
|
|
|
|
2020-07-21 10:51:53 +02:00
|
|
|
it 'sends a reminder to the expert' do
|
2020-07-20 16:26:16 +02:00
|
|
|
get :revive, params: { procedure_id: procedure.id, id: avis.id }
|
|
|
|
expect(AvisMailer).to have_received(:avis_invitation).once.with(avis)
|
2021-02-28 22:20:24 +01:00
|
|
|
expect(flash.notice).to eq("Un mail de relance a été envoyé à #{avis.expert.email}")
|
2017-12-22 17:34:58 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-09-06 11:21:29 +02:00
|
|
|
end
|