Revu de code OK
This commit is contained in:
parent
c454ea28ed
commit
8db705ec94
9 changed files with 79 additions and 87 deletions
|
@ -2,7 +2,31 @@ class Backoffice::DossiersController < ApplicationController
|
|||
before_action :authenticate_gestionnaire!
|
||||
|
||||
def show
|
||||
@dossier = Dossier.find(params[:id])
|
||||
initialize_instance_params params[:id]
|
||||
end
|
||||
|
||||
def valid
|
||||
initialize_instance_params params[:dossier_id]
|
||||
|
||||
@dossier.next_step! 'gestionnaire', 'valid'
|
||||
flash.notice = 'Dossier confirmé avec succès.'
|
||||
|
||||
render 'show'
|
||||
end
|
||||
|
||||
def close
|
||||
initialize_instance_params params[:dossier_id]
|
||||
|
||||
@dossier.next_step! 'gestionnaire', 'close'
|
||||
flash.notice = 'Dossier traité avec succès.'
|
||||
|
||||
render 'show'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def initialize_instance_params dossier_id
|
||||
@dossier = Dossier.find(dossier_id)
|
||||
@entreprise = @dossier.entreprise.decorate
|
||||
@etablissement = @dossier.etablissement
|
||||
@pieces_justificatives = @dossier.pieces_justificatives
|
||||
|
@ -17,25 +41,4 @@ class Backoffice::DossiersController < ApplicationController
|
|||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: '/backoffice')
|
||||
end
|
||||
|
||||
def valid
|
||||
params[:id] = params[:dossier_id]
|
||||
show
|
||||
|
||||
@dossier.next_step! 'gestionnaire', 'valid'
|
||||
flash.notice = 'Dossier confirmé avec succès.'
|
||||
|
||||
render 'show'
|
||||
end
|
||||
|
||||
def close
|
||||
params[:id] = params[:dossier_id]
|
||||
|
||||
show
|
||||
|
||||
@dossier.next_step! 'gestionnaire', 'close'
|
||||
flash.notice = 'Dossier traité avec succès.'
|
||||
|
||||
render 'show'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
|
||||
.col-lg-6.col-md-6
|
||||
=render partial: '/dossiers/pieces_justificatives'
|
||||
-#= 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?
|
||||
|
|
|
@ -11,8 +11,7 @@ Rails.application.routes.draw do
|
|||
devise_for :users, controllers: {
|
||||
sessions: 'users/sessions'
|
||||
}
|
||||
|
||||
#root 'users/dossiers#index'
|
||||
|
||||
root 'root#index'
|
||||
|
||||
get 'france_connect' => 'france_connect#login'
|
||||
|
@ -28,8 +27,6 @@ Rails.application.routes.draw do
|
|||
get '/recapitulatif' => 'recapitulatif#show'
|
||||
post '/recapitulatif/initiate' => 'recapitulatif#initiate'
|
||||
post '/recapitulatif/submit' => 'recapitulatif#submit'
|
||||
# get '/demande' => 'demandes#show'
|
||||
# post '/demande' => 'demandes#update'
|
||||
post '/commentaire' => 'commentaires#create'
|
||||
|
||||
get '/carte/position' => 'carte#get_position'
|
||||
|
|
|
@ -7,7 +7,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
|
||||
describe 'GET #show' do
|
||||
context "l'utilisateur est connecté" do
|
||||
context 'gestionnaire is connected' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
@ -17,47 +17,43 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it "le numéro de dossier n'existe pas" do
|
||||
it 'dossier id doesnt exist' do
|
||||
get :show, id: bad_dossier_id
|
||||
expect(response).to redirect_to('/backoffice')
|
||||
end
|
||||
end
|
||||
|
||||
context "L'utilisateur n'est pas connecté mais le numéro de dossier est correct" do
|
||||
context 'gestionnaire doesnt connected but dossier id is correct' do
|
||||
subject { get :show, id: dossier_id }
|
||||
it { is_expected.to redirect_to('/gestionnaires/sign_in') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #valid' do
|
||||
context 'le gestionnaire valide un dossier' do
|
||||
before do
|
||||
dossier.initiated!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
before do
|
||||
dossier.initiated!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'dossier change is state for validated' do
|
||||
post :valid, dossier_id: dossier_id
|
||||
it 'dossier change is state for validated' do
|
||||
post :valid, dossier_id: dossier_id
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('validated')
|
||||
end
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('validated')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #close' do
|
||||
context 'le gestionnaire taite un dossier' do
|
||||
before do
|
||||
dossier.submitted!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
before do
|
||||
dossier.submitted!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'dossier change is state for closed' do
|
||||
post :close, dossier_id: dossier_id
|
||||
it 'dossier change is state to closed' do
|
||||
post :close, dossier_id: dossier_id
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('closed')
|
||||
end
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('closed')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ RSpec.describe Users::CarteController, type: :controller do
|
|||
sign_out dossier.user
|
||||
end
|
||||
|
||||
it 'redirect to users/sign_in' do
|
||||
it 'redirects to users/sign_in' do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to redirect_to('/users/sign_in')
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe Users::DescriptionController, type: :controller do
|
|||
sign_out dossier.user
|
||||
end
|
||||
|
||||
it 'redirect to users/sign_in' do
|
||||
it 'redirects to users/sign_in' do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to redirect_to('/users/sign_in')
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe UsersController, type: :controller do
|
||||
|
||||
describe '.current_user_dossier' do
|
||||
describe '#current_user_dossier' do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, user: user)}
|
||||
|
||||
|
@ -10,24 +10,24 @@ describe UsersController, type: :controller do
|
|||
sign_in user
|
||||
end
|
||||
|
||||
context 'when no params table exist and no params past at the function' do
|
||||
context 'when no dossier_id is informed' do
|
||||
it { expect{ subject.current_user_dossier }.to raise_error }
|
||||
end
|
||||
|
||||
context 'when no params table exist and params past at the function' do
|
||||
context 'when dossier id is good' do
|
||||
context 'when dossier_id is given as a param' do
|
||||
context 'when dossier id is valid' do
|
||||
it 'returns current user dossier' do
|
||||
expect(subject.current_user_dossier dossier.id).to eq(dossier)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier id is bad' do
|
||||
context 'when dossier id is incorrect' do
|
||||
it { expect{ subject.current_user_dossier 1 }.to raise_error }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when params table exist and no params past at the function' do
|
||||
context 'when dossier id is good' do
|
||||
context 'when no params[] is given' do
|
||||
context 'when dossier id is valid' do
|
||||
before do
|
||||
subject.params[:dossier_id] = dossier.id
|
||||
end
|
||||
|
@ -37,18 +37,18 @@ describe UsersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when dossier id is bad' do
|
||||
context 'when dossier id is incorrect' do
|
||||
it { expect{ subject.current_user_dossier }.to raise_error }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when params table exist and params past at the function' do
|
||||
before do
|
||||
subject.params[:dossier_id] = 1
|
||||
end
|
||||
context 'when dossier_id is given as a param' do
|
||||
before do
|
||||
subject.params[:dossier_id] = 1
|
||||
end
|
||||
|
||||
it 'returns dossier with the id on params past' do
|
||||
expect(subject.current_user_dossier dossier.id).to eq(dossier)
|
||||
it 'returns dossier with the id on params past' do
|
||||
expect(subject.current_user_dossier dossier.id).to eq(dossier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,10 +8,7 @@ RSpec.shared_examples 'not owner of dossier' do |controller, redirect|
|
|||
end
|
||||
|
||||
it 'redirect to home page' do
|
||||
redirect_page = '/'
|
||||
redirect_page = redirect unless redirect.nil?
|
||||
|
||||
expect(response).to redirect_to(redirect_page)
|
||||
expect(response).to redirect_to(redirect || '/')
|
||||
end
|
||||
|
||||
it 'show a flash message error' do
|
||||
|
|
|
@ -14,39 +14,39 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
|||
assign(:commentaires, dossier.commentaires)
|
||||
end
|
||||
|
||||
context 'sur la rendered admin du dossier' do
|
||||
context 'on the dossier admin page' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
it 'la section infos entreprise est présente' do
|
||||
it 'enterprise informations are present' do
|
||||
expect(rendered).to have_selector('#infos_entreprise')
|
||||
end
|
||||
|
||||
it 'la section infos dossier est présente' do
|
||||
it 'dossier informations are present' do
|
||||
expect(rendered).to have_selector('#infos_dossier')
|
||||
end
|
||||
|
||||
it 'le numéro de dossier est présent sur la rendered' do
|
||||
it 'dossier number is present' 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
|
||||
context 'edit link are present' do
|
||||
it 'edit carto' do
|
||||
expect(rendered).to_not have_selector('a[id=modif_carte]')
|
||||
end
|
||||
|
||||
it 'le lien vers description' do
|
||||
it 'edit description' do
|
||||
expect(rendered).to_not have_selector('a[id=modif_description]')
|
||||
end
|
||||
|
||||
it 'le bouton Editer mon dossier n\'est pas present' do
|
||||
it 'Editer mon dossier button doesnt present' do
|
||||
expect(rendered).to_not have_css('#maj_infos')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'gestion des etats du dossier' do
|
||||
context 'dossier state changements' do
|
||||
context 'when dossier have state initiated' do
|
||||
before do
|
||||
dossier.initiated!
|
||||
|
@ -55,7 +55,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
|||
|
||||
it { expect(rendered).to have_content('Soumis') }
|
||||
|
||||
it 'button Valider le dossier est present' do
|
||||
it 'button Valider le dossier is present' do
|
||||
expect(rendered).to have_css('#action_button')
|
||||
expect(rendered).to have_content('Valider le dossier')
|
||||
end
|
||||
|
@ -69,7 +69,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
|||
|
||||
it { expect(rendered).to have_content('Répondu') }
|
||||
|
||||
it 'button Valider le dossier est present' do
|
||||
it 'button Valider le dossier is present' do
|
||||
expect(rendered).to have_css('#action_button')
|
||||
expect(rendered).to have_content('Valider le dossier')
|
||||
end
|
||||
|
@ -83,7 +83,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
|||
|
||||
it { expect(rendered).to have_content('Mis à jour') }
|
||||
|
||||
it 'button Valider le dossier est present' do
|
||||
it 'button Valider le dossier is present' do
|
||||
expect(rendered).to have_css('#action_button')
|
||||
expect(rendered).to have_content('Valider le dossier')
|
||||
end
|
||||
|
@ -97,7 +97,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
|||
|
||||
it { expect(rendered).to have_content('Validé') }
|
||||
|
||||
it 'button Valider le dossier n\'est pas present' do
|
||||
it 'button Valider le dossier is not present' do
|
||||
expect(rendered).not_to have_css('#action_button')
|
||||
expect(rendered).not_to have_content('Valider le dossier')
|
||||
end
|
||||
|
@ -111,12 +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
|
||||
it 'button Traiter le dossier is 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
|
||||
it 'button Valider le dossier is not present' do
|
||||
expect(rendered).not_to have_content('Valider le dossier')
|
||||
end
|
||||
end
|
||||
|
@ -129,7 +129,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
|||
|
||||
it { expect(rendered).to have_content('Traité') }
|
||||
|
||||
it 'button Valider le dossier n\'est pas present' do
|
||||
it 'button Valider le dossier is not present' do
|
||||
expect(rendered).not_to have_css('#action_button')
|
||||
expect(rendered).not_to have_content('Valider le dossier')
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue