Add and use DossiersController#passer_en_instruction

This commit is contained in:
gregoirenovel 2017-11-30 17:11:46 +01:00
parent 56ba310e89
commit eb55dfc0c8
4 changed files with 23 additions and 1 deletions

View file

@ -52,6 +52,14 @@ module NewGestionnaire
redirect_back(fallback_location: procedures_url)
end
def passer_en_instruction
dossier.received!
current_gestionnaire.follow(dossier)
flash.notice = 'Dossier passé en instruction.'
redirect_to dossier_path(procedure, dossier)
end
def create_commentaire
commentaire_hash = commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier)

View file

@ -10,7 +10,7 @@
%h4 En construction
Vous permettez à l'usager de modifier ses réponses au formulaire
%li
= link_to backoffice_dossier_receive_path(dossier, new_ui: true), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do
= link_to passer_en_instruction_dossier_path(dossier.procedure, dossier), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do
.icon.in-progress
.description
%h4 Passer en instruction

View file

@ -254,6 +254,7 @@ Rails.application.routes.draw do
patch 'unarchive'
patch 'annotations' => 'dossiers#update_annotations'
post 'commentaire' => 'dossiers#create_commentaire'
post 'passer-en-instruction' => 'dossiers#passer_en_instruction'
scope :carte do
get 'position'
end

View file

@ -77,6 +77,19 @@ describe NewGestionnaire::DossiersController, type: :controller do
it { expect(response).to redirect_to(procedures_url) }
end
describe '#passer_en_instruction' do
before do
dossier.initiated!
sign_in gestionnaire
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }
dossier.reload
end
it { expect(dossier.state).to eq('received') }
it { is_expected.to redirect_to dossier_path(procedure, dossier) }
it { expect(gestionnaire.follow?(dossier)).to be true }
end
describe '#show #messagerie #annotations_privees #avis' do
before do
dossier.notifications = %w(champs annotations_privees avis commentaire).map{ |type| Notification.create!(type_notif: type) }