Ajout du bouton traité pour les gestionnaires

This commit is contained in:
Xavier J 2015-10-09 12:05:07 +02:00
parent a57b9852b2
commit d53c43a7b0
5 changed files with 37 additions and 1 deletions

View file

@ -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

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -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