- Revu de la page dossier côté gestionnaire

- Ajout des boutons de changement d'état gestionnaire
This commit is contained in:
Xavier J 2015-09-24 16:51:14 +02:00
parent 46211816ed
commit af610a4a04
12 changed files with 420 additions and 166 deletions

View file

@ -18,4 +18,13 @@ class Backoffice::DossiersController < ApplicationController
redirect_to url_for(controller: '/backoffice')
end
def confirme
params[:id] = params[:dossier_id]
show
@dossier.next_step! 'gestionnaire', 'confirme'
flash.notice = 'Dossier confirmé avec succès.'
render 'show'
end
end

View file

@ -1,6 +1,5 @@
class Users::RecapitulatifController < UsersController
def show
@dossier = Dossier.find(params[:dossier_id])
@dossier = @dossier.decorate
@procedure = @dossier.procedure
@ -16,4 +15,22 @@ class Users::RecapitulatifController < UsersController
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(controller: :siret)
end
def propose
show
@dossier.next_step! 'user', 'propose'
flash.notice = 'Dossier soumis avec succès.'
render 'show'
end
def depose
show
@dossier.next_step! 'user', 'depose'
flash.notice = 'Dossier déposé avec succès.'
render 'show'
end
end

View file

@ -16,7 +16,7 @@ class DossierDecorator < Draper::Decorator
when 'draft'
'Brouillon'
when 'proposed'
'Proposé'
'Soumis'
when 'reply'
'Répondu'
when 'updated'

View file

@ -2,9 +2,9 @@
%h1#dossier_id.text-info{ :style => 'text-align:right'}
= "Dossier n°#{@dossier.id}"
%script{type: 'text/javascript'}
="url_carte = '#{@dossier.id}/'"
="ref_dossier = '#{@dossier.ref_dossier_carto}'"
%h3{:class => 'text-success', :style => 'text-align:right'}
= @dossier.state_fr
= render partial: '/dossiers/infos_entreprise'
%br
@ -12,11 +12,10 @@
%br
%br
.content.row
=render partial: '/dossiers/pieces_justificatives'
%br
= render partial: '/users/recapitulatif/commentaires_flux'
%br
%br
-#%script{type: 'text/javascript'}
-# ="url_carte = '#{@dossier.id}/'"
-# ="ref_dossier = '#{@dossier.ref_dossier_carto}'"

View file

@ -38,5 +38,14 @@
-#= pie_chart({"Montant à charge #{(100 - @dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => (@dossier.montant_projet.to_f - @dossier.montant_aide_demande.to_f), "Montant souhaité #{(@dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => @dossier.montant_aide_demande})
%div.row{style: 'text-align:right'}
-unless gestionnaire_signed_in?
-if !@dossier.confirmed? && !@dossier.deposited? && !@dossier.processed?
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description?back_url=recapitulatif"}
= 'Editer mon dossier'
-unless user_signed_in?
-if !@dossier.confirmed? && !@dossier.deposited? && !@dossier.processed?
= 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'

View file

@ -8,11 +8,19 @@
%div.col-md-2.col-lg-2
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
= "Dossier n°#{@dossier.id}"
-#%h3{:class => 'text-success', :style => 'text-align:right'}
-# = @dossier.state_fr
- unless gestionnaire_signed_in?
-if @dossier.draft?
= form_tag(url_for({controller: :recapitulatif, action: :propose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Soumettre mon dossier'
-elsif @dossier.confirmed?
= form_tag(url_for({controller: :recapitulatif, action: :depose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Déposer mon dossier'
-else
%h3{:class => 'text-success', :style => 'text-align:right'}
= @dossier.state_fr
%br

View file

@ -19,6 +19,8 @@ Rails.application.routes.draw do
get '/description/error' => 'description#error'
post 'description' => 'description#create'
get '/recapitulatif' => 'recapitulatif#show'
post '/recapitulatif/propose' => 'recapitulatif#propose'
post '/recapitulatif/depose' => 'recapitulatif#propose'
get '/demande' => 'demandes#show'
post '/demande' => 'demandes#update'
post '/commentaire' => 'commentaires#create'
@ -49,7 +51,9 @@ Rails.application.routes.draw do
namespace :backoffice do
get 'sign_in' => '/gestionnaires/sessions#new'
resources :dossiers, only: [:show]
resources :dossiers do
post 'confirme' => 'dossiers#confirme'
end
resources :commentaires, only: [:create]
end
# The priority is based upon order of creation: first created -> highest priority.

View file

@ -28,4 +28,20 @@ describe Backoffice::DossiersController, type: :controller do
it { is_expected.to redirect_to('/gestionnaires/sign_in') }
end
end
describe 'POST #confirme' do
context 'le gestionnaire valide un dossier' do
before do
dossier.proposed!
sign_in gestionnaire
end
it 'dossier change is state for confirmed' do
post :confirme, dossier_id: dossier_id
dossier.reload
expect(dossier.state).to eq('confirmed')
end
end
end
end

View file

@ -2,13 +2,13 @@ require 'spec_helper'
describe Users::RecapitulatifController, type: :controller do
let(:dossier) { create(:dossier, :with_user) }
let(:bad_dossier_id) { Dossier.count + 100000 }
describe 'GET #show' do
before do
sign_in dossier.user
end
describe 'GET #show' do
it 'returns http success' do
get :show, dossier_id: dossier.id
expect(response).to have_http_status(:success)
@ -19,4 +19,40 @@ describe Users::RecapitulatifController, type: :controller do
expect(response).to redirect_to('/users/siret')
end
end
describe 'POST #propose' do
context 'when an user propose his dossier' do
before do
post :propose, dossier_id: dossier.id
end
it 'dossier change his state for processed' do
dossier.reload
expect(dossier.state).to eq('proposed')
end
it 'a message informe user what his dossier is proposed' do
expect(flash[:notice]).to include('Dossier soumis avec succès.')
end
end
end
describe 'POST #depose' do
context 'when an user depose his dossier' do
before do
dossier.confirmed!
post :depose, dossier_id: dossier.id
end
it 'dossier change his state for deposed' do
dossier.reload
expect(dossier.state).to eq('deposited')
end
it 'a message informe user what his dossier is proposed' do
expect(flash[:notice]).to include('Dossier déposé avec succès.')
end
end
end
end

View file

@ -1,98 +0,0 @@
require 'spec_helper'
feature 'Admin/Dossier#Show Page' do
let(:user) { create(:user) }
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) }
let(:dossier_id) { dossier.id }
before do
login_gestionnaire
visit "/backoffice/dossiers/#{dossier_id}"
end
context 'sur la page admin du dossier' do
scenario 'la section infos entreprise est présente' do
expect(page).to have_selector('#infos_entreprise')
end
scenario 'la section infos dossier est présente' do
expect(page).to have_selector('#infos_dossier')
end
scenario 'le numéro de dossier est présent sur la page' do
expect(page).to have_selector('#dossier_id')
expect(page).to have_content(dossier_id)
end
context 'les liens de modifications sont non présent' do
scenario 'le lien vers carte' do
expect(page).to_not have_selector('a[id=modif_carte]')
end
scenario 'le lien vers description' do
expect(page).to_not have_selector('a[id=modif_description]')
end
end
#TODO réactiver
# context 'la liste des pièces justificatives est présente' do
# context 'Attestation MSA' do
# let(:id_piece_justificative) { 93 }
#
# scenario 'la ligne de la pièce justificative est présente' do
# expect(page).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
# end
#
# scenario 'le bouton "Récupérer" est présent' do
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_selector("a[href='']")
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Récupérer')
# end
# end
#
# context 'Attestation RDI' do
# let(:id_piece_justificative) { 103 }
#
# scenario 'la ligne de la pièce justificative est présente' do
# expect(page).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
# end
#
# scenario 'le libelle "Pièce manquante" est présent' do
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Pièce non fournie')
# end
# end
#
# context 'Devis' do
# let(:id_piece_justificative) { 388 }
# let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
#
# before do
# piece_justificative = dossier.pieces_justificatives.where(type_de_piece_justificative_id: 388).first
# piece_justificative.content = content
# piece_justificative.save!
# visit "/admin/dossiers/#{dossier_id}"
# end
#
# scenario 'la ligne de la pièce justificative est présente' do
# expect(page).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
# end
#
# scenario 'le libelle "Consulter" est présent' do
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}] a")[:href]).to have_content('piece_justificative_388.pdf')
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Consulter')
# end
# end
# end
#
# scenario 'la carte est bien présente' do
# expect(page).to have_selector('#map_qp')
# end
#
# scenario 'la page des sources CSS de l\'API cart est chargée' do
# expect(page).to have_selector('#sources_CSS_api_carto')
# end
#
# scenario 'la page des sources JS backend de l\'API cart est chargée' do
# expect(page).to have_selector('#sources_JS_api_carto_backend')
# end
end
end

View file

@ -0,0 +1,184 @@
require 'spec_helper'
describe 'backoffice/dossiers/show.html.haml', type: :view do
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
let(:dossier_id) { dossier.id }
before do
sign_in create(:gestionnaire)
assign(:dossier, dossier.decorate)
assign(:entreprise, dossier.entreprise.decorate)
assign(:etablissement, dossier.etablissement)
assign(:procedure, dossier.procedure)
assign(:commentaires, dossier.commentaires)
end
context 'sur la rendered admin du dossier' do
before do
render
end
it 'la section infos entreprise est présente' do
expect(rendered).to have_selector('#infos_entreprise')
end
it 'la section infos dossier est présente' do
expect(rendered).to have_selector('#infos_dossier')
end
it 'le numéro de dossier est présent sur la rendered' do
expect(rendered).to have_selector('#dossier_id')
expect(rendered).to have_content(dossier_id)
end
context 'les liens de modifications sont non présent' do
it 'le lien vers carte' do
expect(rendered).to_not have_selector('a[id=modif_carte]')
end
it 'le lien vers description' do
expect(rendered).to_not have_selector('a[id=modif_description]')
end
it 'le bouton Editer mon dossier n\'est pas present' do
expect(rendered).to_not have_css('#maj_infos')
end
end
end
context 'gestion des etats du dossier' do
context 'when dossier have state proposed' do
before do
dossier.proposed!
render
end
it { expect(rendered).to have_content('Soumis') }
it 'button Valider le dossier est present' do
expect(rendered).to have_css('#action_button')
expect(rendered).to have_content('Valider le dossier')
end
end
context 'when dossier have state reply' do
before do
dossier.reply!
render
end
it { expect(rendered).to have_content('Répondu') }
it 'button Valider le dossier est present' do
expect(rendered).to have_css('#action_button')
expect(rendered).to have_content('Valider le dossier')
end
end
context 'when dossier have state update' do
before do
dossier.updated!
render
end
it { expect(rendered).to have_content('Mis à jour') }
it 'button Valider le dossier est present' do
expect(rendered).to have_css('#action_button')
expect(rendered).to have_content('Valider le dossier')
end
end
context 'when dossier have state confirmed' do
before do
dossier.confirmed!
render
end
it { expect(rendered).to have_content('Validé') }
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
context 'when dossier have state deposited' do
before do
dossier.deposited!
render
end
it { expect(rendered).to have_content('Déposé') }
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
context 'when dossier have state processed' do
before do
dossier.processed!
render
end
it { expect(rendered).to have_content('Traité') }
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
end
#TODO réactiver
# context 'la liste des pièces justificatives est présente' do
# context 'Attestation MSA' do
# let(:id_piece_justificative) { 93 }
#
# it 'la ligne de la pièce justificative est présente' do
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
# end
#
# it 'le bouton "Récupérer" est présent' do
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_selector("a[href='']")
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Récupérer')
# end
# end
#
# context 'Attestation RDI' do
# let(:id_piece_justificative) { 103 }
#
# it 'la ligne de la pièce justificative est présente' do
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
# end
#
# it 'le libelle "Pièce manquante" est présent' do
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Pièce non fournie')
# end
# end
#
# context 'Devis' do
# let(:id_piece_justificative) { 388 }
# let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
#
# before do
# piece_justificative = dossier.pieces_justificatives.where(type_de_piece_justificative_id: 388).first
# piece_justificative.content = content
# piece_justificative.save!
# visit "/admin/dossiers/#{dossier_id}"
# end
#
# it 'la ligne de la pièce justificative est présente' do
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
# end
#
# it 'le libelle "Consulter" est présent' do
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}] a")[:href]).to have_content('piece_justificative_388.pdf')
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Consulter')
# end
# end
# end
#
end

View file

@ -1,17 +1,21 @@
require 'spec_helper'
describe 'users/recapitulatif/show.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
let(:dossier) { create(:dossier, :with_user, :with_entreprise, :with_procedure) }
let(:dossier_id) { dossier.id }
before do
assign(:dossier, dossier.decorate)
assign(:procedure, dossier.procedure)
assign(:commentaires, dossier.commentaires)
render
end
context 'sur la rendered recapitulative' do
context 'test de composition de la page' do
before do
render
end
it 'la section infos dossier est présente' do
expect(rendered).to have_selector('#infos_dossier')
end
@ -36,26 +40,92 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
end
end
# context 'visibilité Félicitation' do
# it 'Est affiché quand l\'on vient de la rendered description hors modification' do
# expect(rendered).to have_content('Félicitation')
# end
#
# it 'N\'est pas affiché quand l\'on vient d\'une autre la rendered que description' do
# Capybara.current_session.driver.header('Referer', '/')
#
# expect(rendered).to_not have_content('Félicitation')
# end
#
# it 'N\'est pas affiché quand l\'on vient de la rendered description en modification' do
# Capybara.current_session.driver.header('Referer', '/description?back_url=recapitulatif')
#
# expect(rendered).to_not have_content('Félicitation')
# end
# end
end
context 'buttons to change dossier state' do
context 'when dossier state is draft' do
before do
dossier.draft!
render
end
it 'button Soumettre mon dossier est present' do
expect(rendered).to have_css('#action_button')
expect(rendered).to have_content('Soumettre mon dossier')
end
end
context 'when dossier state is proposed' do
before do
dossier.proposed!
render
end
it { expect(rendered).to have_content('Soumis') }
end
context 'when dossier state is reply' do
before do
dossier.reply!
render
end
#TODO gestionnaire test
it { expect(rendered).to have_content('Répondu') }
end
context 'when dossier state is updated' do
before do
dossier.updated!
render
end
it { expect(rendered).to have_content('Mis à jour') }
end
context 'when dossier state is confirmed' do
before do
dossier.confirmed!
render
end
it 'button Déposer mon dossier est present' do
expect(rendered).to have_css('#action_button')
expect(rendered).to have_content('Déposer mon dossier')
end
it 'button Editer mon dossier n\'est plus present' do
expect(rendered).not_to have_css('#maj_infos')
expect(rendered).not_to have_content('Editer mon dossier')
end
end
context 'when dossier state is deposited' do
before do
dossier.deposited!
render
end
it { expect(rendered).to have_content('Déposé') }
it 'button Editer mon dossier n\'est plus present' do
expect(rendered).not_to have_css('#maj_infos')
expect(rendered).not_to have_content('Editer mon dossier')
end
end
context 'when dossier state is traité' do
before do
dossier.processed!
render
end
it { expect(rendered).to have_content('Traité') }
it 'button Editer mon dossier n\'est plus present' do
expect(rendered).not_to have_css('#maj_infos')
expect(rendered).not_to have_content('Editer mon dossier')
end
end
end
end
end