diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index ee74c65a4..66c54612f 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -60,6 +60,13 @@ module NewGestionnaire redirect_to dossier_path(procedure, dossier) end + def repasser_en_construction + dossier.initiated! + flash.notice = 'Dossier repassé en construction.' + + redirect_to dossier_path(procedure, dossier) + end + def create_commentaire commentaire_hash = commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier) diff --git a/app/views/new_gestionnaire/dossiers/_state_button.html.haml b/app/views/new_gestionnaire/dossiers/_state_button.html.haml index 59091c22d..65eca4956 100644 --- a/app/views/new_gestionnaire/dossiers/_state_button.html.haml +++ b/app/views/new_gestionnaire/dossiers/_state_button.html.haml @@ -18,7 +18,7 @@ - if dossier.en_instruction? %li - = link_to backoffice_dossier_reopen_path(dossier, new_ui: true), method: :post, data: { confirm: "Confirmer vous la réouverture de ce dossier ?" } do + = link_to repasser_en_construction_dossier_path(dossier.procedure, dossier), method: :post, data: { confirm: "Confirmer vous le passage en construction de ce dossier ?" } do .icon.edit .description %h4 Repasser en construction diff --git a/config/routes.rb b/config/routes.rb index 1fd9150b8..15b847679 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -255,6 +255,7 @@ Rails.application.routes.draw do patch 'annotations' => 'dossiers#update_annotations' post 'commentaire' => 'dossiers#create_commentaire' post 'passer-en-instruction' => 'dossiers#passer_en_instruction' + post 'repasser-en-construction' => 'dossiers#repasser_en_construction' scope :carte do get 'position' end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 1afcea5f8..2265e3724 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -90,6 +90,24 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(gestionnaire.follow?(dossier)).to be true } end + describe '#repasser_en_construction' do + before do + dossier.received! + sign_in gestionnaire + end + + subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id} } + + it 'change state to initiated' do + subject + + dossier.reload + expect(dossier.state).to eq('initiated') + end + + it { is_expected.to redirect_to dossier_path(procedure, dossier) } + 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) }