From d53c43a7b006a20fb315e79ba4b7b8e5906a401e Mon Sep 17 00:00:00 2001 From: Xavier J Date: Fri, 9 Oct 2015 12:05:07 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20du=20bouton=20trait=C3=A9=20pour=20les?= =?UTF-8?q?=20gestionnaires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backoffice/dossiers_controller.rb | 11 +++++++++++ app/views/dossiers/_infos_dossier.html.haml | 4 ++++ config/routes.rb | 1 + .../backoffice/dossiers_controller_spec.rb | 16 ++++++++++++++++ .../backoffice/dossiers/show.html.html_spec.rb | 6 +++++- 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 10e4f9ce9..c59e1b962 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -27,4 +27,15 @@ class Backoffice::DossiersController < ApplicationController render 'show' end + + def process_end + params[:id] = params[:dossier_id] + + show + + @dossier.next_step! 'gestionnaire', 'process' + flash.notice = 'Dossier traité avec succès.' + + render 'show' + end end diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index a49503a6f..ce3f4f69a 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -48,4 +48,8 @@ = form_tag(url_for({controller: 'backoffice/dossiers', action: :confirme, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do %button#action_button.btn.btn-success = 'Valider le dossier' + -elsif @dossier.deposited? + = form_tag(url_for({controller: 'backoffice/dossiers', action: :process_end, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do + %button#action_button.btn.btn-success + = 'Traiter le dossier' diff --git a/config/routes.rb b/config/routes.rb index e87b16f3c..543666206 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -59,6 +59,7 @@ Rails.application.routes.draw do get 'sign_in' => '/gestionnaires/sessions#new' resources :dossiers do post 'confirme' => 'dossiers#confirme' + post 'process' => 'dossiers#process_end' end resources :commentaires, only: [:create] end diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 14b87a821..95e115f15 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -44,4 +44,20 @@ describe Backoffice::DossiersController, type: :controller do end end end + + describe 'POST #process_end' do + context 'le gestionnaire taite un dossier' do + before do + dossier.deposited! + sign_in gestionnaire + end + + it 'dossier change is state for processed' do + post :process_end, dossier_id: dossier_id + + dossier.reload + expect(dossier.state).to eq('processed') + end + end + end end diff --git a/spec/views/backoffice/dossiers/show.html.html_spec.rb b/spec/views/backoffice/dossiers/show.html.html_spec.rb index 3f3687f92..27602dd81 100644 --- a/spec/views/backoffice/dossiers/show.html.html_spec.rb +++ b/spec/views/backoffice/dossiers/show.html.html_spec.rb @@ -111,8 +111,12 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do it { expect(rendered).to have_content('Déposé') } + it 'button Traiter le dossier est present' do + expect(rendered).to have_css('#action_button') + expect(rendered).to have_content('Traiter le dossier') + end + it 'button Valider le dossier n\'est pas present' do - expect(rendered).not_to have_css('#action_button') expect(rendered).not_to have_content('Valider le dossier') end end