Merge branch 'develop' into staging
This commit is contained in:
commit
34e4dc06d1
95 changed files with 2658 additions and 579 deletions
66
README.md
Normal file
66
README.md
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
# TPS - TéléProcédure Simplifié
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
TéléProcédure Simplifiée, ou TPS pour les intimes, est une plateforme 100% web et 0% email, conçue afin de répondre au besoin urgent de l'État d'appliquer la directive sur le 100% démat' à l'horizon 2018 pour les démarches administratives.
|
||||||
|
|
||||||
|
|
||||||
|
## Technologies utilisées
|
||||||
|
|
||||||
|
Ruby : 2.1.5
|
||||||
|
Rails : 4.2.0
|
||||||
|
|
||||||
|
|
||||||
|
## Initialisation de l'environnement de développement
|
||||||
|
|
||||||
|
Afin d'initialiser l'environnement de développement, éxécutez la commande suivante :
|
||||||
|
|
||||||
|
bundle install
|
||||||
|
|
||||||
|
|
||||||
|
## Création de la base de données
|
||||||
|
|
||||||
|
L'application utilise une base de donnée Postgresql. Pour en installer une, utilisez la commande suivante :
|
||||||
|
|
||||||
|
sudo apt-get install postgresql
|
||||||
|
|
||||||
|
Les informations nécessaire à l'initialisation de la base doivent être pré-configurer à la main grâce à la procédure suivante :
|
||||||
|
|
||||||
|
su - postgres
|
||||||
|
psql
|
||||||
|
> create user tps with password 'lol' createdb;
|
||||||
|
> \q
|
||||||
|
|
||||||
|
|
||||||
|
Afin de générer la BDD de l'application, il est nécessaire d'éxécuter les commandes suivantes :
|
||||||
|
|
||||||
|
rake db:create db:schema:load db:migrate
|
||||||
|
rake db:create db:schema:load db:migrate RAILS_ENV=test
|
||||||
|
|
||||||
|
|
||||||
|
## Installation de Phantom JS
|
||||||
|
|
||||||
|
Installer PhantomJS qui est utilisé par les tests automatisés de l'application.
|
||||||
|
|
||||||
|
|
||||||
|
## Exécution des tests (Rspec)
|
||||||
|
|
||||||
|
Pour éxécuter les tests de l'application, plusieurs possibilités :
|
||||||
|
|
||||||
|
- Lancer tous les tests
|
||||||
|
|
||||||
|
rake spec
|
||||||
|
rspec
|
||||||
|
|
||||||
|
- Lancer un test en particulier
|
||||||
|
|
||||||
|
rake spec SPEC=file_path/file_name_spec.rb:line_number
|
||||||
|
rspec file_path/file_name_spec.rb:line_number
|
||||||
|
|
||||||
|
- Lancer tous les tests d'un fichier
|
||||||
|
|
||||||
|
rake spec SPEC=file_path/file_name_spec.rb
|
||||||
|
rspec file_path/file_name_spec.rb
|
||||||
|
|
||||||
|
|
||||||
|
|
28
README.rdoc
28
README.rdoc
|
@ -1,28 +0,0 @@
|
||||||
== README
|
|
||||||
|
|
||||||
This README would normally document whatever steps are necessary to get the
|
|
||||||
application up and running.
|
|
||||||
|
|
||||||
Things you may want to cover:
|
|
||||||
|
|
||||||
* Ruby version
|
|
||||||
|
|
||||||
* System dependencies
|
|
||||||
|
|
||||||
* Configuration
|
|
||||||
|
|
||||||
* Database creation
|
|
||||||
|
|
||||||
* Database initialization
|
|
||||||
|
|
||||||
* How to run the test suite
|
|
||||||
|
|
||||||
* Services (job queues, cache servers, search engines, etc.)
|
|
||||||
|
|
||||||
* Deployment instructions
|
|
||||||
|
|
||||||
* ...
|
|
||||||
|
|
||||||
|
|
||||||
Please feel free to use a different markup language if you do not plan to run
|
|
||||||
<tt>rake doc:app</tt>.
|
|
194
app/assets/javascripts/procedure.js
Normal file
194
app/assets/javascripts/procedure.js
Normal file
|
@ -0,0 +1,194 @@
|
||||||
|
var ready = function () {
|
||||||
|
$("#add_type_de_champs_procedure").on('click', function (e) {
|
||||||
|
add_new_type_de('champs');
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#add_type_de_piece_justificative_procedure").on('click', function (e) {
|
||||||
|
add_new_type_de('piece_justificative');
|
||||||
|
});
|
||||||
|
|
||||||
|
add_delete_listener_on_click_for_type_de("champs", "#liste_champs .btn-danger");
|
||||||
|
add_delete_listener_on_click_for_type_de("champs", "#new_type_de_champs .btn-danger");
|
||||||
|
|
||||||
|
add_delete_listener_on_click_for_type_de("piece_justificative", "#liste_piece_justificative .btn-danger");
|
||||||
|
add_delete_listener_on_click_for_type_de("piece_justificative", "#new_type_de_piece_justificative .btn-danger");
|
||||||
|
|
||||||
|
config_up_and_down_button();
|
||||||
|
|
||||||
|
add_action_listener_on_click_for_button_up(".button_up");
|
||||||
|
add_action_listener_on_click_for_button_down(".button_down");
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).ready(ready);
|
||||||
|
$(document).on('page:load', ready);
|
||||||
|
|
||||||
|
function add_delete_listener_on_click_for_type_de(type_libelle, node_id) {
|
||||||
|
$(node_id).on('click', function (e) {
|
||||||
|
var index = (e.target.id).replace('delete_type_de_' + type_libelle + '_', '').replace('_procedure', '');
|
||||||
|
|
||||||
|
delete_type_de(type_libelle, index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_new_type_de(type_libelle) {
|
||||||
|
var CHAMPS = 0,
|
||||||
|
PJ = 1,
|
||||||
|
ERROR = -1;
|
||||||
|
|
||||||
|
if (is_champs_or_pj() == ERROR) return false;
|
||||||
|
|
||||||
|
function is_champs_or_pj() {
|
||||||
|
if (type_libelle == 'champs') return CHAMPS;
|
||||||
|
else if (type_libelle == 'piece_justificative') return PJ;
|
||||||
|
else return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
function which_index() {
|
||||||
|
return (is_champs_or_pj() == CHAMPS ? types_de_champs_index : types_de_piece_justificative_index)
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#liste_" + type_libelle).append($("#type_de_" + type_libelle + "_" + which_index()));
|
||||||
|
$("#new_type_de_" + type_libelle).append($("#type_de_" + type_libelle + "_" + which_index()).clone());
|
||||||
|
|
||||||
|
$("#delete_type_de_" + type_libelle + "_" + which_index() + "_button").show();
|
||||||
|
|
||||||
|
if (is_champs_or_pj() == CHAMPS) {
|
||||||
|
types_de_champs_index++;
|
||||||
|
add_new_type_de_champs_params(which_index());
|
||||||
|
}
|
||||||
|
else if (is_champs_or_pj() == PJ) {
|
||||||
|
types_de_piece_justificative_index++;
|
||||||
|
add_new_type_de_piece_justificative_params(which_index());
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#new_type_de_" + type_libelle + " .form-inline").attr('id', 'type_de_' + type_libelle + '_' + which_index());
|
||||||
|
|
||||||
|
$("#new_type_de_" + type_libelle + " #id_type_de_" + type_libelle + "").attr('name', 'type_de_' + type_libelle + '[' + which_index() + '][id_type_de_' + type_libelle + ']');
|
||||||
|
$("#new_type_de_" + type_libelle + " #id_type_de_" + type_libelle + "").val('');
|
||||||
|
|
||||||
|
$("#new_type_de_" + type_libelle + " #delete").attr('name', 'type_de_' + type_libelle + '[' + which_index() + '][delete]');
|
||||||
|
$("#new_type_de_" + type_libelle + " #delete").val('false');
|
||||||
|
|
||||||
|
$("#new_type_de_" + type_libelle + " #delete_type_de_" + type_libelle + "_" + (which_index() - 1) + "_button").attr('id', "delete_type_de_" + type_libelle + "_" + which_index() + "_button");
|
||||||
|
$("#new_type_de_" + type_libelle + " #delete_type_de_" + type_libelle + "_" + (which_index() - 1) + "_procedure").attr('id', "delete_type_de_" + type_libelle + "_" + which_index() + "_procedure");
|
||||||
|
|
||||||
|
if (is_champs_or_pj() == CHAMPS)
|
||||||
|
add_delete_listener_on_click_for_type_de("champs", "#delete_type_de_champs_" + which_index() + "_procedure");
|
||||||
|
else if (is_champs_or_pj() == PJ)
|
||||||
|
add_delete_listener_on_click_for_type_de("piece_justificative", "#delete_type_de_piece_justificative_" + which_index() + "_procedure");
|
||||||
|
|
||||||
|
$("#new_type_de_" + type_libelle + " #add_type_de_" + type_libelle + "_button").remove();
|
||||||
|
$("#new_type_de_" + type_libelle + " .form-inline").append($("#add_type_de_" + type_libelle + "_button"))
|
||||||
|
|
||||||
|
add_action_listener_on_click_for_button_up("#new_type_de_" + type_libelle + " .button_up")
|
||||||
|
add_action_listener_on_click_for_button_down("#new_type_de_" + type_libelle + " .button_down")
|
||||||
|
|
||||||
|
config_up_and_down_button();
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_new_type_de_champs_params() {
|
||||||
|
$("#new_type_de_champs #libelle").attr('name', 'type_de_champs[' + types_de_champs_index + '][libelle]');
|
||||||
|
$("#new_type_de_champs #libelle").val('');
|
||||||
|
|
||||||
|
$("#new_type_de_champs #description").attr('name', 'type_de_champs[' + types_de_champs_index + '][description]');
|
||||||
|
$("#new_type_de_champs #description").val('');
|
||||||
|
|
||||||
|
$("#new_type_de_champs #type_champs").attr('name', 'type_de_champs[' + types_de_champs_index + '][type]');
|
||||||
|
|
||||||
|
$("#new_type_de_champs .order_place").attr('name', 'type_de_champs[' + types_de_champs_index + '][order_place]');
|
||||||
|
$("#new_type_de_champs .order_place").val(parseInt($("#liste_champs .order_place").last().val()) + 1);
|
||||||
|
|
||||||
|
$("#new_type_de_champs .order_type_de_champs_button").attr('id', 'order_type_de_champs_' + types_de_champs_index + '_button')
|
||||||
|
$("#new_type_de_champs .order_type_de_champs_button .button_up").attr('id', 'order_type_de_champs_' + types_de_champs_index + '_up_procedure')
|
||||||
|
$("#new_type_de_champs .order_type_de_champs_button .button_down").attr('id', 'order_type_de_champs_' + types_de_champs_index + '_down_procedure')
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_new_type_de_piece_justificative_params() {
|
||||||
|
$("#new_type_de_piece_justificative #libelle").attr('name', 'type_de_piece_justificative[' + types_de_piece_justificative_index + '][libelle]');
|
||||||
|
$("#new_type_de_piece_justificative #libelle").val('');
|
||||||
|
|
||||||
|
$("#new_type_de_piece_justificative #description").attr('name', 'type_de_piece_justificative[' + types_de_piece_justificative_index + '][description]');
|
||||||
|
$("#new_type_de_piece_justificative #description").val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_type_de(type_libelle, index) {
|
||||||
|
var delete_node = $("#type_de_" + type_libelle + "_" + index).hide();
|
||||||
|
|
||||||
|
$("#liste_delete_" + type_libelle).append(delete_node);
|
||||||
|
$("#type_de_" + type_libelle + "_" + index + " #delete").val('true');
|
||||||
|
|
||||||
|
if (type_libelle == 'champs') {
|
||||||
|
var next_order_place = parseInt($("#type_de_" + type_libelle + "_" + index + " .order_place").val());
|
||||||
|
var type_de_champs_to_change_order_place = $("#liste_champs .order_place");
|
||||||
|
|
||||||
|
type_de_champs_to_change_order_place.each(function () {
|
||||||
|
if ($(this).val() > next_order_place) {
|
||||||
|
$(this).val(next_order_place++);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#new_type_de_champs .order_place").val(next_order_place);
|
||||||
|
|
||||||
|
config_up_and_down_button();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function config_up_and_down_button() {
|
||||||
|
if ($("#liste_champs .order_place").size() > 0) {
|
||||||
|
var first_index = $("#liste_champs .order_place").first()
|
||||||
|
.attr('name')
|
||||||
|
.replace('type_de_champs[', '')
|
||||||
|
.replace('][order_place]', '');
|
||||||
|
|
||||||
|
var last_index = $("#liste_champs .order_place").last()
|
||||||
|
.attr('name')
|
||||||
|
.replace('type_de_champs[', '')
|
||||||
|
.replace('][order_place]', '');
|
||||||
|
|
||||||
|
$(".button_up").show();
|
||||||
|
$(".button_down").show();
|
||||||
|
$("#liste_champs .order_type_de_champs_button").show();
|
||||||
|
|
||||||
|
$("#order_type_de_champs_" + first_index + "_up_procedure").hide();
|
||||||
|
$("#order_type_de_champs_" + last_index + "_down_procedure").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_action_listener_on_click_for_button_up(node_id) {
|
||||||
|
$(node_id).on('click', function (e) {
|
||||||
|
var index = (e.target.id).replace('order_type_de_champs_', '').replace('_up_procedure', '');
|
||||||
|
var order_place = parseInt($("#type_de_champs_" + index + " .order_place").val());
|
||||||
|
var order_place_before = order_place - 1;
|
||||||
|
|
||||||
|
var node_before = $("input[class='order_place'][value='" + order_place_before + "']").parent();
|
||||||
|
|
||||||
|
var index_before = (node_before.attr('id')).replace('type_de_champs_', '');
|
||||||
|
|
||||||
|
$("#type_de_champs_" + index).insertBefore("#type_de_champs_" + index_before);
|
||||||
|
$("#type_de_champs_" + index_before);
|
||||||
|
|
||||||
|
$("#type_de_champs_" + index_before + " .order_place").val(order_place);
|
||||||
|
$("#type_de_champs_" + index + " .order_place").val(order_place_before);
|
||||||
|
|
||||||
|
config_up_and_down_button();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_action_listener_on_click_for_button_down(node_id) {
|
||||||
|
$(node_id).on('click', function (e) {
|
||||||
|
var index = (e.target.id).replace('order_type_de_champs_', '').replace('_down_procedure', '');
|
||||||
|
var order_place = parseInt($("#type_de_champs_" + index + " .order_place").val());
|
||||||
|
var order_place_after = order_place + 1;
|
||||||
|
|
||||||
|
var node_after = $("input[class='order_place'][value='" + order_place_after + "']").parent();
|
||||||
|
|
||||||
|
var index_after = (node_after.attr('id')).replace('type_de_champs_', '');
|
||||||
|
|
||||||
|
$("#type_de_champs_" + index).insertAfter("#type_de_champs_" + index_after);
|
||||||
|
$("#type_de_champs_" + index_after);
|
||||||
|
|
||||||
|
$("#type_de_champs_" + index_after + " .order_place").val(order_place);
|
||||||
|
$("#type_de_champs_" + index + " .order_place").val(order_place_after);
|
||||||
|
|
||||||
|
config_up_and_down_button();
|
||||||
|
});
|
||||||
|
}
|
17
app/assets/stylesheets/admin_index.scss
Normal file
17
app/assets/stylesheets/admin_index.scss
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
.table {
|
||||||
|
#id {
|
||||||
|
width: 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#libelle {
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#organisation {
|
||||||
|
width: 28%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#direction {
|
||||||
|
width: 22%;
|
||||||
|
}
|
||||||
|
}
|
45
app/assets/stylesheets/description.scss
Normal file
45
app/assets/stylesheets/description.scss
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
@import "bootstrap";
|
||||||
|
@import "bootstrap-datepicker3";
|
||||||
|
|
||||||
|
#description_page #liste_champs{
|
||||||
|
h4{
|
||||||
|
margin-top: 35px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.type_champs-text {
|
||||||
|
@extend .col-md-6;
|
||||||
|
@extend .col-lg-6;
|
||||||
|
|
||||||
|
input[type='text'] {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.type_champs-textarea {
|
||||||
|
@extend .col-md-8;
|
||||||
|
@extend .col-lg-8;
|
||||||
|
|
||||||
|
textarea.form-control {
|
||||||
|
width:100%;
|
||||||
|
height: 133px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.type_champs-number {
|
||||||
|
@extend .col-md-3;
|
||||||
|
@extend .col-lg-3;
|
||||||
|
|
||||||
|
input[type='number']{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.type_champs-datetime {
|
||||||
|
@extend .col-md-2;
|
||||||
|
@extend .col-lg-2;
|
||||||
|
|
||||||
|
input[type='number']{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
114
app/controllers/admin/procedures_controller.rb
Normal file
114
app/controllers/admin/procedures_controller.rb
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
class Admin::ProceduresController < ApplicationController
|
||||||
|
before_action :authenticate_administrateur!
|
||||||
|
|
||||||
|
def index
|
||||||
|
@procedures = Procedure.all
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@procedure = Procedure.find(params[:id])
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
flash.alert = 'Procédure inéxistante'
|
||||||
|
redirect_to admin_procedures_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@procedure ||= Procedure.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@procedure = Procedure.new(create_procedure_params)
|
||||||
|
|
||||||
|
unless @procedure.save
|
||||||
|
flash.now.alert = @procedure.errors.full_messages.join('<br />').html_safe
|
||||||
|
return render 'new'
|
||||||
|
end
|
||||||
|
|
||||||
|
process_types_de_champs_params
|
||||||
|
process_types_de_piece_justificative_params
|
||||||
|
|
||||||
|
flash.notice = 'Procédure enregistrée'
|
||||||
|
redirect_to admin_procedures_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@procedure = Procedure.find(params[:id])
|
||||||
|
|
||||||
|
unless @procedure.update_attributes(create_procedure_params)
|
||||||
|
flash.now.alert = @procedure.errors.full_messages.join('<br />').html_safe
|
||||||
|
return render 'show'
|
||||||
|
end
|
||||||
|
|
||||||
|
process_types_de_champs_params
|
||||||
|
process_types_de_piece_justificative_params
|
||||||
|
|
||||||
|
flash.notice = 'Préocédure modifiée'
|
||||||
|
redirect_to admin_procedures_path
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def process_types_de_champs_params
|
||||||
|
unless params[:type_de_champs].nil? || params[:type_de_champs].size == 0
|
||||||
|
params[:type_de_champs].each do |index, type_de_champs|
|
||||||
|
|
||||||
|
if type_de_champs[:delete] == 'true'
|
||||||
|
unless type_de_champs[:id_type_de_champs].nil? || type_de_champs[:id_type_de_champs] == ''
|
||||||
|
TypeDeChamps.destroy(type_de_champs[:id_type_de_champs])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if type_de_champs[:id_type_de_champs].nil? || type_de_champs[:id_type_de_champs] == ''
|
||||||
|
bdd_object = TypeDeChamps.new
|
||||||
|
else
|
||||||
|
bdd_object = TypeDeChamps.find(type_de_champs[:id_type_de_champs])
|
||||||
|
end
|
||||||
|
|
||||||
|
save_type_de_champs bdd_object, type_de_champs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_types_de_piece_justificative_params
|
||||||
|
unless params[:type_de_piece_justificative].nil? || params[:type_de_piece_justificative].size == 0
|
||||||
|
params[:type_de_piece_justificative].each do |index, type_de_piece_justificative|
|
||||||
|
|
||||||
|
if type_de_piece_justificative[:delete] == 'true'
|
||||||
|
unless type_de_piece_justificative[:id_type_de_piece_justificative].nil? || type_de_piece_justificative[:id_type_de_piece_justificative] == ''
|
||||||
|
TypeDePieceJustificative.destroy(type_de_piece_justificative[:id_type_de_piece_justificative])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if type_de_piece_justificative[:id_type_de_piece_justificative].nil? || type_de_piece_justificative[:id_type_de_piece_justificative] == ''
|
||||||
|
bdd_object = TypeDePieceJustificative.new
|
||||||
|
else
|
||||||
|
bdd_object = TypeDePieceJustificative.find(type_de_piece_justificative[:id_type_de_piece_justificative])
|
||||||
|
end
|
||||||
|
|
||||||
|
save_type_de_piece_justificative bdd_object, type_de_piece_justificative
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_type_de_champs database_object, source
|
||||||
|
database_object.libelle = source[:libelle]
|
||||||
|
database_object.type_champs = source[:type]
|
||||||
|
database_object.description = source[:description]
|
||||||
|
database_object.order_place = source[:order_place]
|
||||||
|
database_object.procedure = @procedure
|
||||||
|
|
||||||
|
database_object.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_type_de_piece_justificative database_object, source
|
||||||
|
database_object.libelle = source[:libelle]
|
||||||
|
database_object.description = source[:description]
|
||||||
|
database_object.procedure = @procedure
|
||||||
|
|
||||||
|
database_object.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_procedure_params
|
||||||
|
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :use_api_carto)
|
||||||
|
end
|
||||||
|
end
|
7
app/controllers/admin_controller.rb
Normal file
7
app/controllers/admin_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class AdminController < ApplicationController
|
||||||
|
|
||||||
|
def index
|
||||||
|
redirect_to(controller: '/administrateurs/sessions', action: :new) unless administrateur_signed_in?
|
||||||
|
redirect_to (admin_procedures_path)
|
||||||
|
end
|
||||||
|
end
|
14
app/controllers/administrateurs/sessions_controller.rb
Normal file
14
app/controllers/administrateurs/sessions_controller.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class Administrateurs::SessionsController < Devise::SessionsController
|
||||||
|
|
||||||
|
def new
|
||||||
|
@administrateur = Administrateur.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def after_sign_in_path_for(resource)
|
||||||
|
admin_procedures_path
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,29 +2,44 @@ class Backoffice::DossiersController < ApplicationController
|
||||||
before_action :authenticate_gestionnaire!
|
before_action :authenticate_gestionnaire!
|
||||||
|
|
||||||
def show
|
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
|
@entreprise = @dossier.entreprise.decorate
|
||||||
@etablissement = @dossier.etablissement
|
@etablissement = @dossier.etablissement
|
||||||
@pieces_justificatives = @dossier.pieces_justificatives
|
@pieces_justificatives = @dossier.pieces_justificatives
|
||||||
@commentaires = @dossier.commentaires.order(created_at: :desc)
|
@commentaires = @dossier.ordered_commentaires
|
||||||
@commentaires = @commentaires.all.decorate
|
@commentaires = @commentaires.all.decorate
|
||||||
@commentaire_email = current_gestionnaire.email
|
@commentaire_email = current_gestionnaire.email
|
||||||
|
|
||||||
@procedure = @dossier.procedure
|
@procedure = @dossier.procedure
|
||||||
|
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
|
@champs = @dossier.ordered_champs
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash.alert = t('errors.messages.dossier_not_found')
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
redirect_to url_for(controller: '/backoffice')
|
redirect_to url_for(controller: '/backoffice')
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,73 +1,3 @@
|
||||||
class DossiersController < ApplicationController
|
class DossiersController < ApplicationController
|
||||||
# def show
|
|
||||||
# @dossier = Dossier.find(params[:id])
|
|
||||||
|
|
||||||
# @etablissement = @dossier.etablissement
|
|
||||||
# @entreprise = @dossier.entreprise.decorate
|
|
||||||
# rescue ActiveRecord::RecordNotFound
|
|
||||||
# flash.alert = t('errors.messages.dossier_not_found')
|
|
||||||
# redirect_to url_for(controller: :siret)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def create
|
|
||||||
# procedure = Procedure.find(params['procedure_id'])
|
|
||||||
# @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
|
||||||
# @entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
|
||||||
# @dossier = Dossier.create
|
|
||||||
# @dossier.draft!
|
|
||||||
|
|
||||||
# @dossier.procedure = procedure
|
|
||||||
# @dossier.save
|
|
||||||
|
|
||||||
# @entreprise.dossier = @dossier
|
|
||||||
# @entreprise.save
|
|
||||||
|
|
||||||
# @etablissement.dossier = @dossier
|
|
||||||
# @etablissement.entreprise = @entreprise
|
|
||||||
# @etablissement.save
|
|
||||||
|
|
||||||
# redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
|
|
||||||
|
|
||||||
# rescue RestClient::ResourceNotFound
|
|
||||||
# flash.alert = t('errors.messages.invalid_siret')
|
|
||||||
# redirect_to url_for(controller: :siret, procedure_id: params['procedure_id'])
|
|
||||||
# rescue ActiveRecord::RecordNotFound
|
|
||||||
# flash.alert = t('errors.messages.dossier_not_found')
|
|
||||||
# redirect_to url_for(controller: :siret)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def update
|
|
||||||
# @dossier = Dossier.find(params[:id])
|
|
||||||
# if checked_autorisation_donnees?
|
|
||||||
# @dossier.update_attributes(update_params)
|
|
||||||
# redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
|
|
||||||
# else
|
|
||||||
# @etablissement = @dossier.etablissement
|
|
||||||
# @entreprise = @dossier.entreprise.decorate
|
|
||||||
# flash.now.alert = 'Les conditions sont obligatoires.'
|
|
||||||
# render 'show'
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# private
|
|
||||||
|
|
||||||
# def update_params
|
|
||||||
# params.require(:dossier).permit(:autorisation_donnees)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def dossier_id_is_present?
|
|
||||||
# @dossier_id != ''
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def checked_autorisation_donnees?
|
|
||||||
# update_params[:autorisation_donnees] == '1'
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def siret
|
|
||||||
# params[:siret]
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def siren
|
|
||||||
# siret[0..8]
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
14
app/controllers/root_controller.rb
Normal file
14
app/controllers/root_controller.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class RootController < ApplicationController
|
||||||
|
def index
|
||||||
|
|
||||||
|
if user_signed_in?
|
||||||
|
redirect_to users_dossiers_path
|
||||||
|
elsif gestionnaire_signed_in?
|
||||||
|
redirect_to backoffice_path
|
||||||
|
elsif administrateur_signed_in?
|
||||||
|
redirect_to admin_procedures_path
|
||||||
|
else
|
||||||
|
redirect_to new_user_session_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,23 +1,24 @@
|
||||||
class Users::CarteController < ApplicationController
|
class Users::CarteController < UsersController
|
||||||
include DossierConcern
|
include DossierConcern
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@dossier = current_dossier
|
@dossier = current_user_dossier
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
redirect_to url_for(controller: :dossiers, action: :index)
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
|
redirect_to url_for(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_ref_api_carto
|
def save_ref_api_carto
|
||||||
dossier = current_dossier
|
dossier = current_user_dossier
|
||||||
|
|
||||||
if dossier.draft?
|
if dossier.draft?
|
||||||
dossier.update_attributes(ref_dossier_carto: params[:ref_dossier])
|
#dossier.update_attributes(ref_dossier_carto: params[:ref_dossier])
|
||||||
redirect_to url_for(controller: :description, action: :show, dossier_id: params[:dossier_id])
|
redirect_to url_for(controller: :description, action: :show, dossier_id: params[:dossier_id])
|
||||||
else
|
else
|
||||||
commentaire_params = {
|
commentaire_params = {
|
||||||
email: 'Modification localisation',
|
email: 'Modification localisation',
|
||||||
body: 'La localisation de la demande a été modifiée. Merci de le prendre en compte.',
|
body: 'La localisation de la demande a été modifiée. Merci de le prendre en compte.',
|
||||||
dossier_id: dossier.id
|
dossier_id: dossier.id
|
||||||
}
|
}
|
||||||
commentaire = Commentaire.new commentaire_params
|
commentaire = Commentaire.new commentaire_params
|
||||||
commentaire.save
|
commentaire.save
|
||||||
|
@ -27,18 +28,12 @@ class Users::CarteController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_position
|
def get_position
|
||||||
dossier = current_dossier
|
tmp_position = Carto::Geocodeur.convert_adresse_to_point(current_user_dossier.etablissement.adresse.gsub("\r\n", ' '))
|
||||||
|
|
||||||
if dossier.position_lat.nil?
|
if !tmp_position.point.nil?
|
||||||
tmp_position = Carto::Geocodeur.convert_adresse_to_point(dossier.etablissement.adresse.gsub("\r\n", ' '))
|
render json: {lon: tmp_position.point.x.to_s, lat: tmp_position.point.y.to_s, dossier_id: params[:dossier_id]}
|
||||||
|
else
|
||||||
if tmp_position.point.nil?
|
render json: {lon: '0', lat: '0', dossier_id: params[:dossier_id]}
|
||||||
dossier.update_attributes(position_lat: '0', position_lon: '0')
|
|
||||||
else
|
|
||||||
dossier.update_attributes(position_lat: tmp_position.point.y, position_lon: tmp_position.point.x)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: { lon: dossier.position_lon, lat: dossier.position_lat, dossier_id: params[:dossier_id] }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
class Users::DescriptionController < ApplicationController
|
class Users::DescriptionController < UsersController
|
||||||
def show
|
def show
|
||||||
@dossier = Dossier.find(params[:dossier_id])
|
@dossier = current_user_dossier
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
|
|
||||||
@procedure = @dossier.procedure
|
@procedure = @dossier.procedure
|
||||||
|
@champs = @dossier.ordered_champs
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash.alert = t('errors.messages.dossier_not_found')
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
redirect_to url_for(controller: :siret)
|
redirect_to url_for(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def error
|
def error
|
||||||
|
@ -17,8 +18,8 @@ class Users::DescriptionController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@dossier = Dossier.find(params[:dossier_id])
|
@dossier = current_user_dossier
|
||||||
unless @dossier.update_attributes(create_params)
|
unless @dossier.update_attributes(create_params)
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
@procedure = @dossier.procedure
|
@procedure = @dossier.procedure
|
||||||
|
|
||||||
|
@ -31,6 +32,13 @@ class Users::DescriptionController < ApplicationController
|
||||||
cerfa.save
|
cerfa.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless params[:champs].nil?
|
||||||
|
@dossier.champs.each do |champ|
|
||||||
|
champ.value = params[:champs]["'#{champ.id}'"]
|
||||||
|
champ.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@dossier.pieces_justificatives.each do |piece_justificative|
|
@dossier.pieces_justificatives.each do |piece_justificative|
|
||||||
unless params["piece_justificative_#{piece_justificative.type}"].nil?
|
unless params["piece_justificative_#{piece_justificative.type}"].nil?
|
||||||
piece_justificative.content = params["piece_justificative_#{piece_justificative.type}"]
|
piece_justificative.content = params["piece_justificative_#{piece_justificative.type}"]
|
||||||
|
@ -45,17 +53,16 @@ class Users::DescriptionController < ApplicationController
|
||||||
commentaire.dossier = @dossier
|
commentaire.dossier = @dossier
|
||||||
commentaire.save
|
commentaire.save
|
||||||
else
|
else
|
||||||
@dossier.proposed!
|
@dossier.initiated!
|
||||||
end
|
end
|
||||||
|
|
||||||
flash.notice = 'Félicitation, votre demande a bien été enregistrée.'
|
flash.notice = 'Félicitation, votre demande a bien été enregistrée.'
|
||||||
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def create_params
|
def create_params
|
||||||
params.permit(:nom_projet, :description, :montant_projet, :montant_aide_demande, :date_previsionnelle)
|
params.permit(:nom_projet, :description)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
class Users::DossiersController < UsersController
|
class Users::DossiersController < UsersController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@dossiers = current_user.dossiers.order(updated_at: 'DESC').decorate
|
@dossiers = current_user.dossiers.order(updated_at: 'DESC').decorate
|
||||||
end
|
end
|
||||||
def show
|
def show
|
||||||
|
|
||||||
@dossier = Dossier.find(params[:id])
|
@dossier = current_user_dossier params[:id]
|
||||||
|
|
||||||
@etablissement = @dossier.etablissement
|
@etablissement = @dossier.etablissement
|
||||||
@entreprise = @dossier.entreprise.decorate
|
@entreprise = @dossier.entreprise.decorate
|
||||||
|
@ -43,7 +44,7 @@ class Users::DossiersController < UsersController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
||||||
@dossier = Dossier.find(params[:id])
|
@dossier = current_user_dossier params[:id]
|
||||||
if checked_autorisation_donnees?
|
if checked_autorisation_donnees?
|
||||||
@dossier.update_attributes(update_params)
|
@dossier.update_attributes(update_params)
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,32 @@
|
||||||
class Users::RecapitulatifController < UsersController
|
class Users::RecapitulatifController < UsersController
|
||||||
def show
|
def show
|
||||||
@dossier = Dossier.find(params[:dossier_id])
|
@dossier = current_user_dossier
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
@procedure = @dossier.procedure
|
@procedure = @dossier.procedure
|
||||||
|
@champs = @dossier.ordered_champs
|
||||||
|
|
||||||
# mettre dans le modele
|
@commentaires = @dossier.ordered_commentaires
|
||||||
@commentaires = @dossier.commentaires.order(created_at: :desc)
|
|
||||||
|
|
||||||
@commentaires = @commentaires.all.decorate
|
@commentaires = @commentaires.all.decorate
|
||||||
|
|
||||||
#TODO load user email
|
@commentaire_email = current_user.email
|
||||||
@commentaire_email = 'user@email'
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash.alert = t('errors.messages.dossier_not_found')
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
redirect_to url_for(controller: :siret)
|
redirect_to url_for(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def propose
|
def initiate
|
||||||
show
|
show
|
||||||
|
|
||||||
@dossier.next_step! 'user', 'propose'
|
@dossier.next_step! 'user', 'initiate'
|
||||||
flash.notice = 'Dossier soumis avec succès.'
|
flash.notice = 'Dossier soumis avec succès.'
|
||||||
|
|
||||||
render 'show'
|
render 'show'
|
||||||
end
|
end
|
||||||
|
|
||||||
def depose
|
def submit
|
||||||
show
|
show
|
||||||
|
|
||||||
@dossier.next_step! 'user', 'depose'
|
@dossier.next_step! 'user', 'submit'
|
||||||
flash.notice = 'Dossier déposé avec succès.'
|
flash.notice = 'Dossier déposé avec succès.'
|
||||||
|
|
||||||
render 'show'
|
render 'show'
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
|
def current_user_dossier dossier_id=nil
|
||||||
|
dossier_id ||= params[:dossier_id]
|
||||||
|
|
||||||
|
current_user.dossiers.find(dossier_id)
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -15,17 +15,17 @@ class DossierDecorator < Draper::Decorator
|
||||||
case state
|
case state
|
||||||
when 'draft'
|
when 'draft'
|
||||||
'Brouillon'
|
'Brouillon'
|
||||||
when 'proposed'
|
when 'initiated'
|
||||||
'Soumis'
|
'Soumis'
|
||||||
when 'reply'
|
when 'replied'
|
||||||
'Répondu'
|
'Répondu'
|
||||||
when 'updated'
|
when 'updated'
|
||||||
'Mis à jour'
|
'Mis à jour'
|
||||||
when 'confirmed'
|
when 'validated'
|
||||||
'Validé'
|
'Validé'
|
||||||
when 'deposited'
|
when 'submitted'
|
||||||
'Déposé'
|
'Déposé'
|
||||||
when 'processed'
|
when 'closed'
|
||||||
'Traité'
|
'Traité'
|
||||||
else
|
else
|
||||||
fail 'State not valid'
|
fail 'State not valid'
|
||||||
|
|
6
app/models/administrateur.rb
Normal file
6
app/models/administrateur.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class Administrateur < ActiveRecord::Base
|
||||||
|
# Include default devise modules. Others available are:
|
||||||
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
|
devise :database_authenticatable, :registerable,
|
||||||
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
end
|
5
app/models/champ.rb
Normal file
5
app/models/champ.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class Champ < ActiveRecord::Base
|
||||||
|
belongs_to :dossier
|
||||||
|
belongs_to :type_de_champs
|
||||||
|
delegate :libelle, :type_champs, :order_place, to: :type_de_champs
|
||||||
|
end
|
|
@ -1,16 +1,17 @@
|
||||||
class Dossier < ActiveRecord::Base
|
class Dossier < ActiveRecord::Base
|
||||||
enum state: { draft: 'draft',
|
enum state: {draft: 'draft',
|
||||||
proposed: 'proposed',
|
initiated: 'initiated',
|
||||||
reply: 'reply',
|
replied: 'replied',
|
||||||
updated: 'updated',
|
updated: 'updated',
|
||||||
confirmed: 'confirmed',
|
validated: 'validated',
|
||||||
deposited: 'deposited',
|
submitted: 'submitted', #-submit_validated
|
||||||
processed: 'processed' }
|
closed: 'closed'} #-processed
|
||||||
|
|
||||||
has_one :etablissement, dependent: :destroy
|
has_one :etablissement, dependent: :destroy
|
||||||
has_one :entreprise, dependent: :destroy
|
has_one :entreprise, dependent: :destroy
|
||||||
has_one :cerfa, dependent: :destroy
|
has_one :cerfa, dependent: :destroy
|
||||||
has_many :pieces_justificatives, dependent: :destroy
|
has_many :pieces_justificatives, dependent: :destroy
|
||||||
|
has_many :champs, dependent: :destroy
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_many :commentaires, dependent: :destroy
|
has_many :commentaires, dependent: :destroy
|
||||||
|
@ -18,16 +19,15 @@ class Dossier < ActiveRecord::Base
|
||||||
delegate :siren, to: :entreprise
|
delegate :siren, to: :entreprise
|
||||||
delegate :siret, to: :etablissement
|
delegate :siret, to: :etablissement
|
||||||
delegate :types_de_piece_justificative, to: :procedure
|
delegate :types_de_piece_justificative, to: :procedure
|
||||||
|
delegate :types_de_champs, to: :procedure
|
||||||
|
|
||||||
before_create :build_default_cerfa
|
before_create :build_default_cerfa
|
||||||
|
|
||||||
after_save :build_default_pieces_justificatives, if: Proc.new { procedure_id_changed? }
|
after_save :build_default_pieces_justificatives, if: Proc.new { procedure_id_changed? }
|
||||||
|
after_save :build_default_champs, if: Proc.new { procedure_id_changed? }
|
||||||
|
|
||||||
validates :nom_projet, presence: true, allow_blank: false, allow_nil: true
|
validates :nom_projet, presence: true, allow_blank: false, allow_nil: true
|
||||||
validates :description, presence: true, allow_blank: false, allow_nil: true
|
validates :description, presence: true, allow_blank: false, allow_nil: true
|
||||||
validates :montant_projet, presence: true, allow_blank: false, allow_nil: true
|
|
||||||
validates :montant_aide_demande, presence: true, allow_blank: false, allow_nil: true
|
|
||||||
validates :date_previsionnelle, presence: true, allow_blank: false, unless: Proc.new { description.nil? }
|
|
||||||
validates :user, presence: true
|
validates :user, presence: true
|
||||||
|
|
||||||
def retrieve_piece_justificative_by_type(type)
|
def retrieve_piece_justificative_by_type(type)
|
||||||
|
@ -35,11 +35,26 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_default_pieces_justificatives
|
def build_default_pieces_justificatives
|
||||||
|
|
||||||
procedure.types_de_piece_justificative.each do |type_de_piece_justificative|
|
procedure.types_de_piece_justificative.each do |type_de_piece_justificative|
|
||||||
PieceJustificative.create(type_de_piece_justificative_id: type_de_piece_justificative.id, dossier_id: id)
|
PieceJustificative.create(type_de_piece_justificative_id: type_de_piece_justificative.id, dossier_id: id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_default_champs
|
||||||
|
procedure.types_de_champs.each do |type_de_champs|
|
||||||
|
Champ.create(type_de_champs_id: type_de_champs.id, dossier_id: id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def ordered_champs
|
||||||
|
champs.joins(', types_de_champs').where('champs.type_de_champs_id = types_de_champs.id').order('order_place')
|
||||||
|
end
|
||||||
|
|
||||||
|
def ordered_commentaires
|
||||||
|
commentaires.order(created_at: :desc)
|
||||||
|
end
|
||||||
|
|
||||||
def sous_domaine
|
def sous_domaine
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
'tps'
|
'tps'
|
||||||
|
@ -49,7 +64,7 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_step! role, action
|
def next_step! role, action
|
||||||
unless %w(propose reply update comment confirme depose process).include?(action)
|
unless %w(initiate update comment valid submit close).include?(action)
|
||||||
fail 'action is not valid'
|
fail 'action is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,20 +74,20 @@ class Dossier < ActiveRecord::Base
|
||||||
|
|
||||||
if role == 'user'
|
if role == 'user'
|
||||||
case action
|
case action
|
||||||
when 'propose'
|
when 'initiate'
|
||||||
if draft?
|
if draft?
|
||||||
proposed!
|
initiated!
|
||||||
end
|
end
|
||||||
when 'depose'
|
when 'submit'
|
||||||
if confirmed?
|
if validated?
|
||||||
deposited!
|
submitted!
|
||||||
end
|
end
|
||||||
when 'update'
|
when 'update'
|
||||||
if reply?
|
if replied?
|
||||||
updated!
|
updated!
|
||||||
end
|
end
|
||||||
when 'comment'
|
when 'comment'
|
||||||
if reply?
|
if replied?
|
||||||
updated!
|
updated!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -80,21 +95,21 @@ class Dossier < ActiveRecord::Base
|
||||||
case action
|
case action
|
||||||
when 'comment'
|
when 'comment'
|
||||||
if updated?
|
if updated?
|
||||||
reply!
|
replied!
|
||||||
elsif proposed?
|
elsif initiated?
|
||||||
reply!
|
replied!
|
||||||
end
|
end
|
||||||
when 'confirme'
|
when 'valid'
|
||||||
if updated?
|
if updated?
|
||||||
confirmed!
|
validated!
|
||||||
elsif reply?
|
elsif replied?
|
||||||
confirmed!
|
validated!
|
||||||
elsif proposed?
|
elsif initiated?
|
||||||
confirmed!
|
validated!
|
||||||
end
|
end
|
||||||
when 'process'
|
when 'close'
|
||||||
if deposited?
|
if submitted?
|
||||||
processed!
|
closed!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -102,15 +117,15 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.a_traiter
|
def self.a_traiter
|
||||||
Dossier.where("state='proposed' OR state='updated' OR state='deposited'").order('updated_at ASC')
|
Dossier.where("state='initiated' OR state='updated' OR state='submitted'").order('updated_at ASC')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.en_attente
|
def self.en_attente
|
||||||
Dossier.where("state='reply' OR state='confirmed'").order('updated_at ASC')
|
Dossier.where("state='replied' OR state='validated'").order('updated_at ASC')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.termine
|
def self.termine
|
||||||
Dossier.where("state='processed'").order('updated_at ASC')
|
Dossier.where("state='closed'").order('updated_at ASC')
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -5,7 +5,6 @@ class PieceJustificative < ActiveRecord::Base
|
||||||
alias_attribute :type, :type_de_piece_justificative_id
|
alias_attribute :type, :type_de_piece_justificative_id
|
||||||
mount_uploader :content, PieceJustificativeUploader
|
mount_uploader :content, PieceJustificativeUploader
|
||||||
|
|
||||||
|
|
||||||
def empty?
|
def empty?
|
||||||
content.blank?
|
content.blank?
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
class Procedure < ActiveRecord::Base
|
class Procedure < ActiveRecord::Base
|
||||||
has_many :types_de_piece_justificative
|
has_many :types_de_piece_justificative
|
||||||
|
has_many :types_de_champs
|
||||||
has_many :dossiers
|
has_many :dossiers
|
||||||
belongs_to :evenement_vie
|
|
||||||
|
|
||||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||||
validates :lien_demarche, presence: true, allow_blank: false, allow_nil: false
|
|
||||||
end
|
end
|
||||||
|
|
14
app/models/type_de_champs.rb
Normal file
14
app/models/type_de_champs.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class TypeDeChamps < ActiveRecord::Base
|
||||||
|
enum type_champs: {text: 'text',
|
||||||
|
textarea: 'textarea',
|
||||||
|
datetime: 'datetime',
|
||||||
|
number: 'number'
|
||||||
|
}
|
||||||
|
|
||||||
|
belongs_to :procedure
|
||||||
|
has_many :champ
|
||||||
|
|
||||||
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
validates :type_champs, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
validates :order_place, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
end
|
31
app/views/admin/procedures/_informations.html.haml
Normal file
31
app/views/admin/procedures/_informations.html.haml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
%br
|
||||||
|
|
||||||
|
-{libelle: 'Libellé*', description: 'Description*', lien_demarche: 'Lien démarche', organisation: 'Organisation', direction: 'Direction'}.each do |key, value|
|
||||||
|
.form-group{class: ('has-error' if @procedure.errors.messages[key])}
|
||||||
|
%h4
|
||||||
|
=value
|
||||||
|
=f.text_field key, class: 'form-control', placeholder: value
|
||||||
|
|
||||||
|
%br
|
||||||
|
|
||||||
|
%label{ style:'font-weight:normal' }
|
||||||
|
=f.check_box :use_api_carto
|
||||||
|
Utilisation de l'API Carto
|
||||||
|
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%h3.text-info
|
||||||
|
Liste des champs à remplir pour un dossier
|
||||||
|
|
||||||
|
=render partial: 'admin/procedures/types_de_champs/liste', locals: {f: f}
|
||||||
|
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%h3.text-info
|
||||||
|
Liste des pièces justificatives à fournir pour un dossier
|
||||||
|
|
||||||
|
=render partial: 'admin/procedures/types_de_piece_justificative/liste', locals: {f: f}
|
||||||
|
|
||||||
|
%br
|
||||||
|
%div.small{style:'text-align:right'}
|
||||||
|
*Attributs obligatoires
|
17
app/views/admin/procedures/index.html.haml
Normal file
17
app/views/admin/procedures/index.html.haml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
= link_to("Nouvelle procédure", "/admin/procedures/new", class: 'btn btn-success', style: 'float:right')
|
||||||
|
%h2 Gestion des procédures
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%table.table
|
||||||
|
%thead
|
||||||
|
%th#id ID
|
||||||
|
%th#libelle Libellé
|
||||||
|
%th#organisation Organisation
|
||||||
|
%th#direction Direction
|
||||||
|
- @procedures.each do |procedure|
|
||||||
|
%tr
|
||||||
|
%td= procedure.id
|
||||||
|
%td
|
||||||
|
= link_to(procedure.libelle, "/admin/procedures/#{procedure.id}")
|
||||||
|
%td= procedure.organisation
|
||||||
|
%td= procedure.direction
|
8
app/views/admin/procedures/new.html.haml
Normal file
8
app/views/admin/procedures/new.html.haml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
%h2 Nouvelle procédure
|
||||||
|
|
||||||
|
#procedure_new.section.section-label
|
||||||
|
= form_for @procedure, url: {controller: 'admin/procedures', action: :create} do |f|
|
||||||
|
=render partial: 'informations', locals: {f: f}
|
||||||
|
=f.submit 'Valider', class: 'btn btn-info', style: 'float:right'
|
||||||
|
%br
|
||||||
|
%br
|
9
app/views/admin/procedures/show.html.haml
Normal file
9
app/views/admin/procedures/show.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
%h2.text-info
|
||||||
|
=@procedure.libelle
|
||||||
|
|
||||||
|
#procedure_new.section.section-label
|
||||||
|
= form_for @procedure, url: {controller: 'admin/procedures', action: :update} do |f|
|
||||||
|
=render partial: 'informations', locals: {f: f}
|
||||||
|
=f.submit 'Editer', class: 'btn btn-success', style: 'float:right'
|
||||||
|
%br
|
||||||
|
%br
|
40
app/views/admin/procedures/types_de_champs/_form.html.haml
Normal file
40
app/views/admin/procedures/types_de_champs/_form.html.haml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
.form-inline{id:"type_de_champs_#{index}", style: 'padding-bottom:8px'}
|
||||||
|
.form-group{ style: 'padding-right: 2%' }
|
||||||
|
%h4 Libellé
|
||||||
|
%input.form-control#libelle{ type: 'text', placeholder: 'Libelle', name:"type_de_champs[#{index}][libelle]", size: 40, value: ("#{ type_de_champs.libelle }" unless type_de_champs.nil? ) }
|
||||||
|
|
||||||
|
.form-group{ style: 'padding-right: 2%' }
|
||||||
|
%h4 Type
|
||||||
|
%select.form-control#type_champs{ name: "type_de_champs[#{index}][type]" }
|
||||||
|
%option{ value: 'text', selected: (type_de_champs.type_champs == 'text' unless type_de_champs.nil?)}
|
||||||
|
Simple texte
|
||||||
|
%option{ value: 'textarea', selected: (type_de_champs.type_champs == 'textarea' unless type_de_champs.nil?)}
|
||||||
|
Texte multi-lignes
|
||||||
|
%option{ value: 'datetime', selected: (type_de_champs.type_champs == 'datetime' unless type_de_champs.nil?)}
|
||||||
|
Date
|
||||||
|
%option{ value: 'number', selected: (type_de_champs.type_champs == 'number' unless type_de_champs.nil?)}
|
||||||
|
Valeur numérique
|
||||||
|
|
||||||
|
.form-group{ style: 'padding-right: 2%' }
|
||||||
|
%h4
|
||||||
|
Description
|
||||||
|
%textarea.form-control#description{cols: 60, placeholder: 'Description', name: "type_de_champs[#{index}][description]"}
|
||||||
|
=("#{ type_de_champs.description }" unless type_de_champs.nil? )
|
||||||
|
|
||||||
|
%input.order_place{type: 'hidden', name: "type_de_champs[#{index}][order_place]", value: (("#{ type_de_champs.order_place }" unless type_de_champs.nil?) || index+1)}
|
||||||
|
%input#id_type_de_champs{type: 'hidden', name: "type_de_champs[#{index}][id_type_de_champs]", value: (("#{ type_de_champs.id}" unless type_de_champs.nil?))}
|
||||||
|
%input#delete{type: 'hidden', name: "type_de_champs[#{index}][delete]", value: 'false'}
|
||||||
|
|
||||||
|
-if type_de_champs.nil?
|
||||||
|
.form-group#add_type_de_champs_button
|
||||||
|
%br
|
||||||
|
%button.form-control.btn.btn-success#add_type_de_champs_procedure{type: 'button'} Ajouter
|
||||||
|
|
||||||
|
.form-group.order_type_de_champs_button{id: "order_type_de_champs_#{index}_button", style: ("display:none" if type_de_champs.nil?)}
|
||||||
|
%br
|
||||||
|
%button.form-control.btn.btn-default.button_up.fa.fa-chevron-up{type: 'button', id: "order_type_de_champs_#{index}_up_procedure"}
|
||||||
|
%button.form-control.btn.btn-default.button_down.fa.fa-chevron-down{type: 'button', id: "order_type_de_champs_#{index}_down_procedure"}
|
||||||
|
|
||||||
|
.form-group{id: "delete_type_de_champs_#{index}_button", style: ("display:none" if type_de_champs.nil?)}
|
||||||
|
%br
|
||||||
|
%button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button', id: "delete_type_de_champs_#{index}_procedure"}
|
12
app/views/admin/procedures/types_de_champs/_liste.html.haml
Normal file
12
app/views/admin/procedures/types_de_champs/_liste.html.haml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#liste_champs
|
||||||
|
-if @procedure.types_de_champs.size > 0
|
||||||
|
- @procedure.types_de_champs.order(:order_place).each_with_index do |type_de_champs, index|
|
||||||
|
=render partial: 'admin/procedures/types_de_champs/form', locals:{ type_de_champs: type_de_champs, index: index }
|
||||||
|
|
||||||
|
#liste_delete_champs
|
||||||
|
|
||||||
|
#new_type_de_champs
|
||||||
|
=render partial: 'admin/procedures/types_de_champs/form', locals:{ type_de_champs: nil, index: @procedure.types_de_champs.size }
|
||||||
|
|
||||||
|
%script{ type:'text/javascript' }
|
||||||
|
="var types_de_champs_index = #{@procedure.types_de_champs.size}"
|
|
@ -0,0 +1,22 @@
|
||||||
|
.form-inline{id:"type_de_piece_justificative_#{index}", style: 'padding-bottom:8px'}
|
||||||
|
.form-group{ style: 'padding-right: 2%' }
|
||||||
|
%h4 Libellé
|
||||||
|
%input.form-control#libelle{ type: 'text', placeholder: 'Libelle', name:"type_de_piece_justificative[#{index}][libelle]", size: 40, value: ("#{ type_de_piece_justificative.libelle }" unless type_de_piece_justificative.nil? ) }
|
||||||
|
|
||||||
|
.form-group{ style: 'padding-right: 2%' }
|
||||||
|
%h4
|
||||||
|
Description
|
||||||
|
%textarea.form-control#description{cols: 60, placeholder: 'Description', name: "type_de_piece_justificative[#{index}][description]"}
|
||||||
|
=("#{ type_de_piece_justificative.description }" unless type_de_piece_justificative.nil? )
|
||||||
|
|
||||||
|
%input#id_type_de_piece_justificative{type: 'hidden', name: "type_de_piece_justificative[#{index}][id_type_de_piece_justificative]", value: (("#{ type_de_piece_justificative.id}" unless type_de_piece_justificative.nil?))}
|
||||||
|
%input#delete{type: 'hidden', name: "type_de_piece_justificative[#{index}][delete]", value: 'false'}
|
||||||
|
|
||||||
|
-if type_de_piece_justificative.nil?
|
||||||
|
.form-group#add_type_de_piece_justificative_button
|
||||||
|
%br
|
||||||
|
%button.form-control.btn.btn-success#add_type_de_piece_justificative_procedure{type: 'button'} Ajouter
|
||||||
|
|
||||||
|
.form-group{id: "delete_type_de_piece_justificative_#{index}_button", style: ("display:none" if type_de_piece_justificative.nil?)}
|
||||||
|
%br
|
||||||
|
%button.form-control.btn.btn-danger.fa.fa-trash-o{type: 'button', id: "delete_type_de_piece_justificative_#{index}_procedure"}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#liste_piece_justificative
|
||||||
|
-if @procedure.types_de_piece_justificative.size > 0
|
||||||
|
- @procedure.types_de_piece_justificative.order(:libelle).each_with_index do |type_de_piece_justificative, index|
|
||||||
|
=render partial: 'admin/procedures/types_de_piece_justificative/form', locals:{ type_de_piece_justificative: type_de_piece_justificative, index: index }
|
||||||
|
|
||||||
|
#liste_delete_piece_justificative
|
||||||
|
|
||||||
|
#new_type_de_piece_justificative
|
||||||
|
=render partial: 'admin/procedures/types_de_piece_justificative/form', locals:{ type_de_piece_justificative: nil, index: @procedure.types_de_piece_justificative.size }
|
||||||
|
|
||||||
|
%script{ type:'text/javascript' }
|
||||||
|
="var types_de_piece_justificative_index = #{@procedure.types_de_piece_justificative.size}"
|
10
app/views/administrateurs/sessions/new.html.haml
Normal file
10
app/views/administrateurs/sessions/new.html.haml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
%h1 Bienvenue sur TPS - Administration
|
||||||
|
%br
|
||||||
|
#gestionnaire_login
|
||||||
|
= form_for @administrateur, url: {controller: 'administrateurs/sessions', action: :create } do |f|
|
||||||
|
.form-group-lg
|
||||||
|
.form-group
|
||||||
|
= f.text_field :email, class: 'form-control', placeholder: 'Email'
|
||||||
|
.form-group
|
||||||
|
= f.password_field :password, class: 'form-control', placeholder: 'Mot de passe'
|
||||||
|
= f.submit 'Se connecter', class: %w(btn btn-lg btn-success), data: { disable_with: 'Connexion', submit: true }
|
|
@ -6,25 +6,6 @@
|
||||||
%h3.text-info
|
%h3.text-info
|
||||||
= @dossier.nom_projet
|
= @dossier.nom_projet
|
||||||
|
|
||||||
%br
|
|
||||||
%div.row
|
|
||||||
.col-lg-6.col-md-6
|
|
||||||
%h4 Montant total
|
|
||||||
%p{style:'margin-left:5%'}
|
|
||||||
=number_to_currency(@dossier.montant_projet.to_f, :unit => " ", :separator => ",", :delimiter => " ")
|
|
||||||
!='€'
|
|
||||||
|
|
||||||
.col-lg-6.col-md-6
|
|
||||||
%h4 Début du projet souhaité
|
|
||||||
%p{style:'margin-left:5%'}
|
|
||||||
= @dossier.date_fr
|
|
||||||
%div.row
|
|
||||||
.col-lg-6.col-md-6
|
|
||||||
%h4 Montant souhaité
|
|
||||||
%p{style:'margin-left:5%'}
|
|
||||||
=number_to_currency(@dossier.montant_aide_demande.to_f, :unit => " ", :separator => ",", :delimiter => " ")
|
|
||||||
!='€'
|
|
||||||
%br
|
|
||||||
.description
|
.description
|
||||||
- begin
|
- begin
|
||||||
- @dossier.description.split(/(?:\n\r?|\r\n?')/).each do |line|
|
- @dossier.description.split(/(?:\n\r?|\r\n?')/).each do |line|
|
||||||
|
@ -32,20 +13,32 @@
|
||||||
%br
|
%br
|
||||||
- rescue
|
- rescue
|
||||||
=''
|
=''
|
||||||
|
|
||||||
.col-lg-6.col-md-6
|
.col-lg-6.col-md-6
|
||||||
=render partial: '/dossiers/pieces_justificatives'
|
=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})
|
|
||||||
|
%br
|
||||||
|
-unless @champs.nil?
|
||||||
|
%table.table#liste_champs
|
||||||
|
-@champs.each do |champ|
|
||||||
|
%tr
|
||||||
|
%th{ style: 'width:25%' }
|
||||||
|
=champ.libelle
|
||||||
|
%td
|
||||||
|
=champ.value
|
||||||
|
|
||||||
%div.row{style: 'text-align:right'}
|
%div.row{style: 'text-align:right'}
|
||||||
-unless gestionnaire_signed_in?
|
-unless gestionnaire_signed_in?
|
||||||
-if !@dossier.confirmed? && !@dossier.deposited? && !@dossier.processed?
|
-if !@dossier.validated? && !@dossier.submitted? && !@dossier.closed?
|
||||||
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description?back_url=recapitulatif"}
|
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description?back_url=recapitulatif"}
|
||||||
= 'Editer mon dossier'
|
= 'Editer mon dossier'
|
||||||
|
|
||||||
-unless user_signed_in?
|
-unless user_signed_in?
|
||||||
-if !@dossier.confirmed? && !@dossier.deposited? && !@dossier.processed?
|
-if !@dossier.validated? && !@dossier.submitted? && !@dossier.closed?
|
||||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :confirme, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||||
%button#action_button.btn.btn-success
|
%button#action_button.btn.btn-success
|
||||||
= 'Valider le dossier'
|
= 'Valider le dossier'
|
||||||
|
-elsif @dossier.submitted?
|
||||||
|
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||||
|
%button#action_button.btn.btn-success
|
||||||
|
= 'Traiter le dossier'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%h1 Bienvenue sur TPS
|
%h1 Bienvenue sur TPS - Gestionnaire
|
||||||
%br
|
%br
|
||||||
#gestionnaire_login
|
#gestionnaire_login
|
||||||
= form_for @gestionnaire, url: {controller: 'gestionnaires/sessions', action: :create } do |f|
|
= form_for @gestionnaire, url: {controller: 'gestionnaires/sessions', action: :create } do |f|
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
%div{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
%div{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
||||||
= current_gestionnaire.email
|
= current_gestionnaire.email
|
||||||
= link_to "Déconnexion", '/gestionnaires/sign_out', method: :delete, :class => 'btn btn-md'
|
= link_to "Déconnexion", '/gestionnaires/sign_out', method: :delete, :class => 'btn btn-md'
|
||||||
|
-elsif administrateur_signed_in?
|
||||||
|
%div{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
||||||
|
= current_administrateur.email
|
||||||
|
= link_to "Déconnexion", '/administrateurs/sign_out', method: :delete, :class => 'btn btn-md'
|
||||||
|
|
||||||
- elsif user_signed_in?
|
- elsif user_signed_in?
|
||||||
%div.user{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
%div.user{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
||||||
-if current_user.loged_in_with_france_connect
|
-if current_user.loged_in_with_france_connect
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
%h1 coucou
|
|
|
@ -2,8 +2,8 @@
|
||||||
%h2 Description de votre projet
|
%h2 Description de votre projet
|
||||||
%br
|
%br
|
||||||
|
|
||||||
|
-#TODO use form_for
|
||||||
= form_tag(url_for({controller: :description, action: :create, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST', multipart: true) do
|
= form_tag(url_for({controller: :description, action: :create, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST', multipart: true) do
|
||||||
|
|
||||||
%div
|
%div
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
@ -14,22 +14,28 @@
|
||||||
.col-md-12
|
.col-md-12
|
||||||
%h4 Description de votre projet *
|
%h4 Description de votre projet *
|
||||||
= text_area_tag :description, @dossier.description, rows: '6', placeholder: 'Description du projet', class: 'form-control'
|
= text_area_tag :description, @dossier.description, rows: '6', placeholder: 'Description du projet', class: 'form-control'
|
||||||
%br
|
|
||||||
.row
|
|
||||||
.col-lg-6.col-md-6
|
|
||||||
%h4 Montant du projet *
|
|
||||||
= number_field_tag :montant_projet, @dossier.montant_projet, class: 'form-control', placeholder: 'Montant du projet'
|
|
||||||
!= '€'
|
|
||||||
|
|
||||||
.col-lg-6.col-md-6
|
#liste_champs
|
||||||
%h4 Montant des aides que vous sollicitez *
|
-unless @champs.nil?
|
||||||
= number_field_tag :montant_aide_demande, @dossier.montant_aide_demande, class: 'form-control', placeholder: 'Montant des aides'
|
-@champs.each do |champ|
|
||||||
!='€'
|
.row
|
||||||
%br
|
%div{class: "type_champs-#{champ.type_champs}"}
|
||||||
.row
|
%h4
|
||||||
.col-lg-6.col-md-6
|
= champ.libelle
|
||||||
%h4 Date prévisionnelle du début de votre projet *
|
|
||||||
= text_field_tag :date_previsionnelle, @dossier.date_previsionnelle, placeholder: 'Date prévisionnelle', class: 'form-control', 'data-provide' => 'datepicker', 'data-date-format' => 'dd/mm/yyyy'
|
-if champ.type_champs == 'textarea'
|
||||||
|
%textarea.form-control{name:"champs['#{champ.id}']",
|
||||||
|
placeholder: champ.libelle,
|
||||||
|
id: "champs_#{champ.id}"}
|
||||||
|
=champ.value
|
||||||
|
-else
|
||||||
|
%input.form-control{name:"champs['#{champ.id}']",
|
||||||
|
placeholder: champ.libelle,
|
||||||
|
id: "champs_#{champ.id}",
|
||||||
|
value: champ.value,
|
||||||
|
type:"#{champ.type_champs}",
|
||||||
|
'data-provide' => ('datepicker' if champ.type_champs == 'datetime'),
|
||||||
|
'data-date-format' => ('dd/mm/yyyy' if champ.type_champs == 'datetime')}
|
||||||
|
|
||||||
%br
|
%br
|
||||||
%h3 Documents administratifs
|
%h3 Documents administratifs
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
%div.row#recap_dossier
|
.row#recap_dossier
|
||||||
%div.col-md-2.col-lg-2
|
.col-md-2.col-lg-2
|
||||||
%h2
|
%h2
|
||||||
='Récapitulatif'
|
='Récapitulatif'
|
||||||
|
|
||||||
%div.col-md-8.col-lg-8
|
.col-md-7.col-lg-7
|
||||||
|
|
||||||
%div.col-md-2.col-lg-2
|
.col-md-3.col-lg-3
|
||||||
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
|
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
|
||||||
= "Dossier n°#{@dossier.id}"
|
= "Dossier n°#{@dossier.id}"
|
||||||
|
|
||||||
- unless gestionnaire_signed_in?
|
- unless gestionnaire_signed_in?
|
||||||
-if @dossier.draft?
|
-if @dossier.draft?
|
||||||
= form_tag(url_for({controller: :recapitulatif, action: :propose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
= form_tag(url_for({controller: :recapitulatif, action: :initiate, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||||
%button#action_button.btn.btn-success
|
%button#action_button.btn.btn-success
|
||||||
= 'Soumettre mon dossier'
|
= 'Soumettre mon dossier'
|
||||||
-elsif @dossier.confirmed?
|
-elsif @dossier.validated?
|
||||||
= form_tag(url_for({controller: :recapitulatif, action: :depose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||||
%button#action_button.btn.btn-success
|
%button#action_button.btn.btn-success
|
||||||
= 'Déposer mon dossier'
|
= 'Déposer mon dossier'
|
||||||
-else
|
-else
|
||||||
|
|
|
@ -30,5 +30,15 @@
|
||||||
|
|
||||||
= render "users/shared/links"
|
= render "users/shared/links"
|
||||||
|
|
||||||
|
%div{style:'text-align:center'}
|
||||||
|
\-
|
||||||
|
%br
|
||||||
|
%a{href: '/gestionnaires/sign_in'}
|
||||||
|
= 'Gestionnaire'
|
||||||
|
%br
|
||||||
|
%a{href: '/administrateurs/sign_in'}
|
||||||
|
= 'Administrateur'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||||
inflect.acronym 'API'
|
inflect.acronym 'API'
|
||||||
inflect.irregular 'piece_justificative', 'pieces_justificatives'
|
inflect.irregular 'piece_justificative', 'pieces_justificatives'
|
||||||
inflect.irregular 'type_de_piece_justificative', 'types_de_piece_justificative'
|
inflect.irregular 'type_de_piece_justificative', 'types_de_piece_justificative'
|
||||||
|
inflect.irregular 'type_de_champs', 'types_de_champs'
|
||||||
end
|
end
|
||||||
|
|
||||||
# These inflection rules are supported but not enabled by default:
|
# These inflection rules are supported but not enabled by default:
|
||||||
|
|
|
@ -78,7 +78,7 @@ fr:
|
||||||
not_saved:
|
not_saved:
|
||||||
one: "1 erreur a empêché ce(tte) %{resource} d'être sauvegardé(e) :"
|
one: "1 erreur a empêché ce(tte) %{resource} d'être sauvegardé(e) :"
|
||||||
other: "%{count} erreurs ont empêché ce(tte) %{resource} d'être sauvegardé(e) :"
|
other: "%{count} erreurs ont empêché ce(tte) %{resource} d'être sauvegardé(e) :"
|
||||||
dossier_not_found: "Le dossier n'existe pas"
|
dossier_not_found: "Le dossier n'existe pas ou vous n'y avez pas accès."
|
||||||
invalid_siret: "Le siret est incorrect"
|
invalid_siret: "Le siret est incorrect"
|
||||||
france_connect:
|
france_connect:
|
||||||
connexion: "Erreur lors de la connexion à France Connect."
|
connexion: "Erreur lors de la connexion à France Connect."
|
||||||
|
|
12
config/locales/models/procedure/fr.yml
Normal file
12
config/locales/models/procedure/fr.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
fr:
|
||||||
|
activerecord:
|
||||||
|
errors:
|
||||||
|
models:
|
||||||
|
procedure:
|
||||||
|
attributes:
|
||||||
|
libelle:
|
||||||
|
blank: Attribut manquant
|
||||||
|
description:
|
||||||
|
blank: Attribut manquant
|
||||||
|
lien_demarche:
|
||||||
|
blank: Attribut manquant
|
|
@ -1,14 +1,18 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
devise_for :users, controllers: {
|
devise_for :administrateurs, controllers: {
|
||||||
sessions: 'users/sessions'
|
sessions: 'administrateurs/sessions'
|
||||||
}
|
}, skip: [:password, :registrations]
|
||||||
|
|
||||||
devise_for :gestionnaires, controllers: {
|
devise_for :gestionnaires, controllers: {
|
||||||
sessions: 'gestionnaires/sessions'
|
sessions: 'gestionnaires/sessions'
|
||||||
}, skip: [:password, :registrations]
|
}, skip: [:password, :registrations]
|
||||||
|
|
||||||
root 'users/dossiers#index'
|
devise_for :users, controllers: {
|
||||||
|
sessions: 'users/sessions'
|
||||||
|
}
|
||||||
|
|
||||||
|
root 'root#index'
|
||||||
|
|
||||||
get 'france_connect' => 'france_connect#login'
|
get 'france_connect' => 'france_connect#login'
|
||||||
get 'france_connect/callback' => 'france_connect#callback'
|
get 'france_connect/callback' => 'france_connect#callback'
|
||||||
|
@ -21,10 +25,8 @@ Rails.application.routes.draw do
|
||||||
get '/description/error' => 'description#error'
|
get '/description/error' => 'description#error'
|
||||||
post 'description' => 'description#create'
|
post 'description' => 'description#create'
|
||||||
get '/recapitulatif' => 'recapitulatif#show'
|
get '/recapitulatif' => 'recapitulatif#show'
|
||||||
post '/recapitulatif/propose' => 'recapitulatif#propose'
|
post '/recapitulatif/initiate' => 'recapitulatif#initiate'
|
||||||
post '/recapitulatif/depose' => 'recapitulatif#depose'
|
post '/recapitulatif/submit' => 'recapitulatif#submit'
|
||||||
get '/demande' => 'demandes#show'
|
|
||||||
post '/demande' => 'demandes#update'
|
|
||||||
post '/commentaire' => 'commentaires#create'
|
post '/commentaire' => 'commentaires#create'
|
||||||
|
|
||||||
get '/carte/position' => 'carte#get_position'
|
get '/carte/position' => 'carte#get_position'
|
||||||
|
@ -35,33 +37,27 @@ Rails.application.routes.draw do
|
||||||
resource :dossiers
|
resource :dossiers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get 'admin' => 'admin#index'
|
||||||
|
|
||||||
# resources :dossiers do
|
namespace :admin do
|
||||||
|
get 'sign_in' => '/administrateurs/sessions#new'
|
||||||
|
resources :procedures do
|
||||||
# # get '/carte/position' => 'carte#get_position'
|
|
||||||
# # get '/carte' => 'carte#show'
|
|
||||||
# # post '/carte' => 'carte#save_ref_api_carto'
|
|
||||||
|
|
||||||
# # get '/description' => 'description#show'
|
|
||||||
# # get '/description/error' => 'description#error'
|
|
||||||
# # post 'description' => 'description#create'
|
|
||||||
|
|
||||||
|
|
||||||
# post '/commentaire' => 'commentaires#create'
|
|
||||||
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
get 'backoffice' => 'backoffice#index'
|
get 'backoffice' => 'backoffice#index'
|
||||||
|
|
||||||
namespace :backoffice do
|
namespace :backoffice do
|
||||||
get 'sign_in' => '/gestionnaires/sessions#new'
|
get 'sign_in' => '/gestionnaires/sessions#new'
|
||||||
|
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
post 'confirme' => 'dossiers#confirme'
|
post 'valid' => 'dossiers#valid'
|
||||||
|
post 'close' => 'dossiers#close'
|
||||||
end
|
end
|
||||||
resources :commentaires, only: [:create]
|
resources :commentaires, only: [:create]
|
||||||
end
|
end
|
||||||
|
|
||||||
# The priority is based upon order of creation: first created -> highest priority.
|
# The priority is based upon order of creation: first created -> highest priority.
|
||||||
# See how all your routes lay out with "rake routes".
|
# See how all your routes lay out with "rake routes".
|
||||||
|
|
||||||
|
|
42
db/migrate/20151023132121_devise_create_administrateurs.rb
Normal file
42
db/migrate/20151023132121_devise_create_administrateurs.rb
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
class DeviseCreateAdministrateurs < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table(:administrateurs) do |t|
|
||||||
|
## Database authenticatable
|
||||||
|
t.string :email, null: false, default: ""
|
||||||
|
t.string :encrypted_password, null: false, default: ""
|
||||||
|
|
||||||
|
## Recoverable
|
||||||
|
t.string :reset_password_token
|
||||||
|
t.datetime :reset_password_sent_at
|
||||||
|
|
||||||
|
## Rememberable
|
||||||
|
t.datetime :remember_created_at
|
||||||
|
|
||||||
|
## Trackable
|
||||||
|
t.integer :sign_in_count, default: 0, null: false
|
||||||
|
t.datetime :current_sign_in_at
|
||||||
|
t.datetime :last_sign_in_at
|
||||||
|
t.inet :current_sign_in_ip
|
||||||
|
t.inet :last_sign_in_ip
|
||||||
|
|
||||||
|
## Confirmable
|
||||||
|
# t.string :confirmation_token
|
||||||
|
# t.datetime :confirmed_at
|
||||||
|
# t.datetime :confirmation_sent_at
|
||||||
|
# t.string :unconfirmed_email # Only if using reconfirmable
|
||||||
|
|
||||||
|
## Lockable
|
||||||
|
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
||||||
|
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
||||||
|
# t.datetime :locked_at
|
||||||
|
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :administrateurs, :email, unique: true
|
||||||
|
add_index :administrateurs, :reset_password_token, unique: true
|
||||||
|
# add_index :administrateurs, :confirmation_token, unique: true
|
||||||
|
# add_index :administrateurs, :unlock_token, unique: true
|
||||||
|
end
|
||||||
|
end
|
11
db/migrate/20151026155158_create_types_de_champs.rb
Normal file
11
db/migrate/20151026155158_create_types_de_champs.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateTypesDeChamps < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :types_de_champs do |t|
|
||||||
|
t.string :libelle
|
||||||
|
t.string :type
|
||||||
|
t.integer :order_place
|
||||||
|
|
||||||
|
t.belongs_to :procedure
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
class ChangeAttributsToTypeDeChamps < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :types_de_champs, :type, :type_champs
|
||||||
|
add_column :types_de_champs, :description, :text
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeStateProposedToSubmitted < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
Dossier.where(state: 'proposed').update_all(state: 'submitted')
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeStatereplyToReplied < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
Dossier.where(state: 'reply').update_all(state: 'replied')
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
class ChangeStateConfirmedToValidated < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
Dossier.where(state: 'confirmed').update_all(state: 'validated')
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeStateDepositedToSubmitValidate < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
Dossier.where(state: 'deposited').update_all(state: 'submit_validated')
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeStateProcessedToClosed < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
Dossier.where(state: 'processed').update_all(state: 'closed')
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeStateSubmittedToInitiated < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
Dossier.where(state: 'submitted').update_all(state: 'initiated')
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeStateSubmitValidatedToSubmitted < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
Dossier.where(state: 'submit_validated').update_all(state: 'submitted')
|
||||||
|
end
|
||||||
|
end
|
12
db/migrate/20151102163051_delete_attributs_to_dossier.rb
Normal file
12
db/migrate/20151102163051_delete_attributs_to_dossier.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class DeleteAttributsToDossier < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :dossiers, :montant_projet
|
||||||
|
remove_column :dossiers, :montant_aide_demande
|
||||||
|
remove_column :dossiers, :date_previsionnelle
|
||||||
|
remove_column :dossiers, :position_lat
|
||||||
|
|
||||||
|
remove_column :dossiers, :position_lon
|
||||||
|
remove_column :dossiers, :ref_dossier_carto
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
9
db/migrate/20151103091603_create_champs.rb
Normal file
9
db/migrate/20151103091603_create_champs.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class CreateChamps < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :champs do |t|
|
||||||
|
t.string :value
|
||||||
|
end
|
||||||
|
add_reference :champs, :type_de_champs, references: :types_de_champs
|
||||||
|
add_reference :champs, :dossier, references: :dossiers
|
||||||
|
end
|
||||||
|
end
|
40
db/schema.rb
40
db/schema.rb
|
@ -11,11 +11,29 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20151008090835) do
|
ActiveRecord::Schema.define(version: 20151103091603) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
create_table "administrateurs", force: :cascade do |t|
|
||||||
|
t.string "email", default: "", null: false
|
||||||
|
t.string "encrypted_password", default: "", null: false
|
||||||
|
t.string "reset_password_token"
|
||||||
|
t.datetime "reset_password_sent_at"
|
||||||
|
t.datetime "remember_created_at"
|
||||||
|
t.integer "sign_in_count", default: 0, null: false
|
||||||
|
t.datetime "current_sign_in_at"
|
||||||
|
t.datetime "last_sign_in_at"
|
||||||
|
t.inet "current_sign_in_ip"
|
||||||
|
t.inet "last_sign_in_ip"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "administrateurs", ["email"], name: "index_administrateurs_on_email", unique: true, using: :btree
|
||||||
|
add_index "administrateurs", ["reset_password_token"], name: "index_administrateurs_on_reset_password_token", unique: true, using: :btree
|
||||||
|
|
||||||
create_table "cerfas", force: :cascade do |t|
|
create_table "cerfas", force: :cascade do |t|
|
||||||
t.string "content"
|
t.string "content"
|
||||||
t.integer "dossier_id"
|
t.integer "dossier_id"
|
||||||
|
@ -23,6 +41,12 @@ ActiveRecord::Schema.define(version: 20151008090835) do
|
||||||
|
|
||||||
add_index "cerfas", ["dossier_id"], name: "index_cerfas_on_dossier_id", using: :btree
|
add_index "cerfas", ["dossier_id"], name: "index_cerfas_on_dossier_id", using: :btree
|
||||||
|
|
||||||
|
create_table "champs", force: :cascade do |t|
|
||||||
|
t.string "value"
|
||||||
|
t.integer "type_de_champs_id"
|
||||||
|
t.integer "dossier_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "commentaires", force: :cascade do |t|
|
create_table "commentaires", force: :cascade do |t|
|
||||||
t.string "email"
|
t.string "email"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
|
@ -36,14 +60,8 @@ ActiveRecord::Schema.define(version: 20151008090835) do
|
||||||
create_table "dossiers", force: :cascade do |t|
|
create_table "dossiers", force: :cascade do |t|
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.boolean "autorisation_donnees"
|
t.boolean "autorisation_donnees"
|
||||||
t.string "position_lat"
|
|
||||||
t.string "position_lon"
|
|
||||||
t.string "ref_dossier_carto"
|
|
||||||
t.string "nom_projet"
|
t.string "nom_projet"
|
||||||
t.string "montant_projet"
|
|
||||||
t.string "montant_aide_demande"
|
|
||||||
t.integer "procedure_id"
|
t.integer "procedure_id"
|
||||||
t.date "date_previsionnelle"
|
|
||||||
t.datetime "created_at", default: '2015-09-22 09:25:29'
|
t.datetime "created_at", default: '2015-09-22 09:25:29'
|
||||||
t.datetime "updated_at", default: '2015-09-22 09:25:29'
|
t.datetime "updated_at", default: '2015-09-22 09:25:29'
|
||||||
t.string "state"
|
t.string "state"
|
||||||
|
@ -124,6 +142,14 @@ ActiveRecord::Schema.define(version: 20151008090835) do
|
||||||
t.boolean "use_api_carto", default: false
|
t.boolean "use_api_carto", default: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "types_de_champs", force: :cascade do |t|
|
||||||
|
t.string "libelle"
|
||||||
|
t.string "type_champs"
|
||||||
|
t.integer "order_place"
|
||||||
|
t.integer "procedure_id"
|
||||||
|
t.text "description"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "types_de_piece_justificative", force: :cascade do |t|
|
create_table "types_de_piece_justificative", force: :cascade do |t|
|
||||||
t.string "libelle"
|
t.string "libelle"
|
||||||
t.string "description"
|
t.string "description"
|
||||||
|
|
461
spec/controllers/admin/procedures_controller_spec.rb
Normal file
461
spec/controllers/admin/procedures_controller_spec.rb
Normal file
|
@ -0,0 +1,461 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Admin::ProceduresController, type: :controller do
|
||||||
|
let(:admin) { create(:administrateur) }
|
||||||
|
|
||||||
|
let(:bad_procedure_id) { 100000 }
|
||||||
|
|
||||||
|
let(:libelle) { 'Procédure de test' }
|
||||||
|
let(:description) { 'Description de test' }
|
||||||
|
let(:organisation) { 'Organisation de test' }
|
||||||
|
let(:direction) { 'Direction de test' }
|
||||||
|
let(:lien_demarche) { 'http://localhost.com' }
|
||||||
|
let(:use_api_carto) { '1' }
|
||||||
|
|
||||||
|
let(:procedure_params) {
|
||||||
|
{
|
||||||
|
libelle: libelle,
|
||||||
|
description: description,
|
||||||
|
organisation: organisation,
|
||||||
|
direction: direction,
|
||||||
|
lien_demarche: lien_demarche,
|
||||||
|
use_api_carto: use_api_carto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:types_de_champs_params) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: 'Champs de test',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test',
|
||||||
|
order_place: 1},
|
||||||
|
'1' =>
|
||||||
|
{libelle: 'Champs de test 2',
|
||||||
|
type: 'text',
|
||||||
|
description: 'Description de test 2',
|
||||||
|
order_place: 2}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:types_de_champs_params_errors) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: '',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test',
|
||||||
|
order_place: 1},
|
||||||
|
'1' =>
|
||||||
|
{libelle: 'Champs de test 2',
|
||||||
|
type: 'text',
|
||||||
|
description: 'Description de test 2',
|
||||||
|
order_place: 2}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:types_de_piece_justificative_params_errors) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: '',
|
||||||
|
description: 'Description de test'},
|
||||||
|
'1' =>
|
||||||
|
{libelle: 'Champs de test 2',
|
||||||
|
description: 'Description de test 2'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:types_de_piece_justificative_params) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: 'PJ de test',
|
||||||
|
description: 'Description de test'},
|
||||||
|
'1' =>
|
||||||
|
{libelle: 'PJ de test 2',
|
||||||
|
description: 'Description de test 2'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in admin
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #show' do
|
||||||
|
let(:procedure) { create(:procedure, :with_type_de_champs, :with_two_type_de_piece_justificative) }
|
||||||
|
let(:procedure_id) { procedure.id }
|
||||||
|
|
||||||
|
subject { get :show, id: procedure_id }
|
||||||
|
|
||||||
|
context 'when user is not connected' do
|
||||||
|
before do
|
||||||
|
sign_out admin
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(subject).to redirect_to new_administrateur_session_path }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user is connected' do
|
||||||
|
context 'when procedure exist' do
|
||||||
|
let(:procedure_id) { procedure.id }
|
||||||
|
it { expect(subject).to have_http_status(:success) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when procedure doesn't exist" do
|
||||||
|
let(:procedure_id) { bad_procedure_id }
|
||||||
|
|
||||||
|
it { expect(subject).to redirect_to admin_procedures_path }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'POST #create' do
|
||||||
|
context 'when all attributs are filled' do
|
||||||
|
describe 'new procedure in database' do
|
||||||
|
subject { post :create, procedure: procedure_params }
|
||||||
|
|
||||||
|
it { expect { subject }.to change { Procedure.count }.by(1) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure is correctly save' do
|
||||||
|
before do
|
||||||
|
post :create, procedure: procedure_params
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'procedure attributs in database' do
|
||||||
|
subject { Procedure.last }
|
||||||
|
|
||||||
|
it { expect(subject.libelle).to eq(libelle) }
|
||||||
|
it { expect(subject.description).to eq(description) }
|
||||||
|
it { expect(subject.organisation).to eq(organisation) }
|
||||||
|
it { expect(subject.direction).to eq(direction) }
|
||||||
|
it { expect(subject.lien_demarche).to eq(lien_demarche) }
|
||||||
|
it { expect(subject.use_api_carto).to be_truthy }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(subject).to redirect_to(admin_procedures_path) }
|
||||||
|
|
||||||
|
it { expect(flash[:notice]).to be_present }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when many attributs are not valid' do
|
||||||
|
let(:libelle) { '' }
|
||||||
|
let(:description) { '' }
|
||||||
|
|
||||||
|
describe 'no new procedure in database' do
|
||||||
|
subject { post :create, procedure: procedure_params }
|
||||||
|
|
||||||
|
it { expect { subject }.to change { Procedure.count }.by(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'flash message is present' do
|
||||||
|
before do
|
||||||
|
post :create, procedure: procedure_params
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(flash[:alert]).to be_present }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'type_de_champs processing' do
|
||||||
|
before do
|
||||||
|
post :create, procedure: procedure_params, type_de_champs: types_de_champs_params
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { Procedure.last }
|
||||||
|
|
||||||
|
context 'when no type de champs is filled' do
|
||||||
|
let(:types_de_champs_params) { {} }
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when two types de champs are filled' do
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(2) }
|
||||||
|
|
||||||
|
describe ' check types de champs attributs present into database' do
|
||||||
|
subject { TypeDeChamps.all }
|
||||||
|
|
||||||
|
it { expect(subject[0].libelle).to eq(types_de_champs_params['0'][:libelle]) }
|
||||||
|
it { expect(subject[0].type_champs).to eq(types_de_champs_params['0'][:type]) }
|
||||||
|
it { expect(subject[0].description).to eq(types_de_champs_params['0'][:description]) }
|
||||||
|
it { expect(subject[0].order_place).to eq(types_de_champs_params['0'][:order_place]) }
|
||||||
|
|
||||||
|
it { expect(subject[1].libelle).to eq(types_de_champs_params['1'][:libelle]) }
|
||||||
|
it { expect(subject[1].type_champs).to eq(types_de_champs_params['1'][:type]) }
|
||||||
|
it { expect(subject[1].description).to eq(types_de_champs_params['1'][:description]) }
|
||||||
|
it { expect(subject[1].order_place).to eq(types_de_champs_params['1'][:order_place]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when one of two types de champs have not a libelle' do
|
||||||
|
let(:types_de_champs_params) { types_de_champs_params_errors }
|
||||||
|
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(1) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'type_de_piece_justificative processing' do
|
||||||
|
before do
|
||||||
|
post :create, procedure: procedure_params, type_de_piece_justificative: types_de_piece_justificative_params
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { Procedure.last }
|
||||||
|
|
||||||
|
context 'when no type de piece justificative is filled' do
|
||||||
|
let(:types_de_piece_justificative_params) { {} }
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when two types de piece justificative are filled' do
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(2) }
|
||||||
|
|
||||||
|
describe ' check types de piece justificative attributs present into database' do
|
||||||
|
subject { TypeDePieceJustificative.all }
|
||||||
|
|
||||||
|
it { expect(subject[0].libelle).to eq(types_de_piece_justificative_params['0'][:libelle]) }
|
||||||
|
it { expect(subject[0].description).to eq(types_de_piece_justificative_params['0'][:description]) }
|
||||||
|
|
||||||
|
it { expect(subject[1].libelle).to eq(types_de_piece_justificative_params['1'][:libelle]) }
|
||||||
|
it { expect(subject[1].description).to eq(types_de_piece_justificative_params['1'][:description]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when one of two types de piece justificative have not a libelle' do
|
||||||
|
let(:types_de_piece_justificative_params) { types_de_piece_justificative_params_errors }
|
||||||
|
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(1) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'PUT #update' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs, :with_two_type_de_piece_justificative) }
|
||||||
|
|
||||||
|
context 'when administrateur is not connected' do
|
||||||
|
before do
|
||||||
|
sign_out admin
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { put :update, id: procedure.id }
|
||||||
|
|
||||||
|
it { expect(subject).to redirect_to new_administrateur_session_path }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when administrateur is connected' do
|
||||||
|
before do
|
||||||
|
put :update, id: procedure.id, procedure: procedure_params, type_de_champs: types_de_champs_params, type_de_piece_justificative: types_de_piece_justificative_params
|
||||||
|
procedure.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when all attributs are informated' do
|
||||||
|
let(:libelle) { 'Blable' }
|
||||||
|
let(:description) { 'blabla' }
|
||||||
|
let(:organisation) { 'plop' }
|
||||||
|
let(:direction) { 'plap' }
|
||||||
|
let(:lien_demarche) { 'http://plip.com' }
|
||||||
|
let(:use_api_carto) { '0' }
|
||||||
|
|
||||||
|
describe 'procedure attributs in database' do
|
||||||
|
subject { procedure }
|
||||||
|
|
||||||
|
it { expect(subject.libelle).to eq(libelle) }
|
||||||
|
it { expect(subject.description).to eq(description) }
|
||||||
|
it { expect(subject.organisation).to eq(organisation) }
|
||||||
|
it { expect(subject.direction).to eq(direction) }
|
||||||
|
it { expect(subject.lien_demarche).to eq(lien_demarche) }
|
||||||
|
it { expect(subject.use_api_carto).to be_falsey }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(subject).to redirect_to(admin_procedures_path) }
|
||||||
|
it { expect(flash[:notice]).to be_present }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when many attributs are not valid' do
|
||||||
|
let(:libelle) { '' }
|
||||||
|
let(:description) { '' }
|
||||||
|
|
||||||
|
describe 'flash message is present' do
|
||||||
|
it { expect(flash[:alert]).to be_present }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'type_de_champs processing' do
|
||||||
|
subject { procedure }
|
||||||
|
|
||||||
|
context 'when no type de champs is filled' do
|
||||||
|
let(:types_de_champs_params) { {} }
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(1) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when two types de champs are filled' do
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(3) }
|
||||||
|
|
||||||
|
describe ' check types de champs attributs added into database' do
|
||||||
|
subject { procedure.types_de_champs }
|
||||||
|
|
||||||
|
it { expect(subject[1].libelle).to eq(types_de_champs_params['0'][:libelle]) }
|
||||||
|
it { expect(subject[1].type_champs).to eq(types_de_champs_params['0'][:type]) }
|
||||||
|
it { expect(subject[1].description).to eq(types_de_champs_params['0'][:description]) }
|
||||||
|
it { expect(subject[1].order_place).to eq(types_de_champs_params['0'][:order_place]) }
|
||||||
|
|
||||||
|
it { expect(subject[2].libelle).to eq(types_de_champs_params['1'][:libelle]) }
|
||||||
|
it { expect(subject[2].type_champs).to eq(types_de_champs_params['1'][:type]) }
|
||||||
|
it { expect(subject[2].description).to eq(types_de_champs_params['1'][:description]) }
|
||||||
|
it { expect(subject[2].order_place).to eq(types_de_champs_params['1'][:order_place]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when one of two types de champs have not a libelle' do
|
||||||
|
let(:procedure) { create(:procedure) }
|
||||||
|
let(:types_de_champs_params) { types_de_champs_params_errors }
|
||||||
|
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(1) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user edit the filed' do
|
||||||
|
let(:types_de_champs_params) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: 'Champs de test editée',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test editée',
|
||||||
|
order_place: 1,
|
||||||
|
id_type_de_champs: procedure.types_de_champs.first.id}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(1) }
|
||||||
|
|
||||||
|
describe ' check types de champs attributs updated into database' do
|
||||||
|
subject { procedure.types_de_champs.first }
|
||||||
|
|
||||||
|
it { expect(subject.libelle).to eq(types_de_champs_params['0'][:libelle]) }
|
||||||
|
it { expect(subject.type_champs).to eq(types_de_champs_params['0'][:type]) }
|
||||||
|
it { expect(subject.description).to eq(types_de_champs_params['0'][:description]) }
|
||||||
|
it { expect(subject.order_place).to eq(types_de_champs_params['0'][:order_place]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when delete a type de champs' do
|
||||||
|
let(:types_de_champs_params) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: 'Champs de test editée',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test editée',
|
||||||
|
order_place: 1,
|
||||||
|
delete: 'true',
|
||||||
|
id_type_de_champs: procedure.types_de_champs.first.id}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when delete a type de champs present in database and a type champ not present in database' do
|
||||||
|
let(:types_de_champs_params) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: 'Champs de test editée',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test editée',
|
||||||
|
order_place: 1,
|
||||||
|
delete: 'true',
|
||||||
|
id_type_de_champs: procedure.types_de_champs.first.id},
|
||||||
|
'1' =>
|
||||||
|
{libelle: 'Champs de test editée',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test editée',
|
||||||
|
order_place: 1,
|
||||||
|
delete: 'true',
|
||||||
|
id_type_de_champs: ''}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it { expect(subject.types_de_champs.size).to eq(0) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'type_de_piece_justificative processing' do
|
||||||
|
subject { procedure }
|
||||||
|
|
||||||
|
context 'when no type de piece justificative is filled' do
|
||||||
|
let(:types_de_piece_justificative_params) { {} }
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(2) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when two types de piece justificative are filled' do
|
||||||
|
let(:procedure) { create(:procedure) }
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(2) }
|
||||||
|
|
||||||
|
describe ' check types de piece justificative attributs added into database' do
|
||||||
|
subject { procedure.types_de_piece_justificative }
|
||||||
|
|
||||||
|
it { expect(subject[0].libelle).to eq(types_de_piece_justificative_params['0'][:libelle]) }
|
||||||
|
it { expect(subject[0].description).to eq(types_de_piece_justificative_params['0'][:description]) }
|
||||||
|
|
||||||
|
it { expect(subject[1].libelle).to eq(types_de_piece_justificative_params['1'][:libelle]) }
|
||||||
|
it { expect(subject[1].description).to eq(types_de_piece_justificative_params['1'][:description]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when one of two types de piece justificative have not a libelle' do
|
||||||
|
let(:types_de_piece_justificative_params) { types_de_piece_justificative_params_errors }
|
||||||
|
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(3) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when one types de piece justificative is edit' do
|
||||||
|
let(:types_de_piece_justificative_params) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: 'PJ de test editée',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test editée',
|
||||||
|
order_place: 1,
|
||||||
|
id_type_de_piece_justificative: procedure.types_de_piece_justificative.first.id}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(2) }
|
||||||
|
|
||||||
|
describe ' check types de piece justificative attributs updated into database' do
|
||||||
|
subject { procedure.types_de_piece_justificative.first }
|
||||||
|
|
||||||
|
it { expect(subject.libelle).to eq(types_de_piece_justificative_params['0'][:libelle]) }
|
||||||
|
it { expect(subject.description).to eq(types_de_piece_justificative_params['0'][:description]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when delete a type de piece justificative' do
|
||||||
|
let(:types_de_piece_justificative_params) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: 'PJ de test editée',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test editée',
|
||||||
|
order_place: 1,
|
||||||
|
delete: 'true',
|
||||||
|
id_type_de_piece_justificative: procedure.types_de_piece_justificative.first.id}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(1) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when delete a type de piece justificative present in database and a type piece justificative not present in database' do
|
||||||
|
let(:types_de_piece_justificative_params) {
|
||||||
|
{'0' =>
|
||||||
|
{libelle: 'PJ de test editée',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test editée',
|
||||||
|
order_place: 1,
|
||||||
|
delete: 'true',
|
||||||
|
id_type_de_piece_justificative: procedure.types_de_piece_justificative.first.id},
|
||||||
|
'1' =>
|
||||||
|
{libelle: 'PJ de test editée',
|
||||||
|
type: 'number',
|
||||||
|
description: 'Description de test editée',
|
||||||
|
order_place: 1,
|
||||||
|
delete: 'true',
|
||||||
|
id_type_de_piece_justificative: ''}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it { expect(subject.types_de_piece_justificative.size).to eq(1) }
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -30,7 +30,7 @@ describe Backoffice::CommentairesController, type: :controller do
|
||||||
|
|
||||||
subject { dossier.state }
|
subject { dossier.state }
|
||||||
|
|
||||||
it {is_expected.to eq('reply')}
|
it {is_expected.to eq('replied')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
let(:gestionnaire) { create(:gestionnaire) }
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
context "l'utilisateur est connecté" do
|
context 'gestionnaire is connected' do
|
||||||
before do
|
before do
|
||||||
sign_in gestionnaire
|
sign_in gestionnaire
|
||||||
end
|
end
|
||||||
|
@ -17,31 +17,43 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "le numéro de dossier n'existe pas" do
|
it 'dossier id doesnt exist' do
|
||||||
get :show, id: bad_dossier_id
|
get :show, id: bad_dossier_id
|
||||||
expect(response).to redirect_to('/backoffice')
|
expect(response).to redirect_to('/backoffice')
|
||||||
end
|
end
|
||||||
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 }
|
subject { get :show, id: dossier_id }
|
||||||
it { is_expected.to redirect_to('/gestionnaires/sign_in') }
|
it { is_expected.to redirect_to('/gestionnaires/sign_in') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #confirme' do
|
describe 'POST #valid' do
|
||||||
context 'le gestionnaire valide un dossier' do
|
before do
|
||||||
before do
|
dossier.initiated!
|
||||||
dossier.proposed!
|
sign_in gestionnaire
|
||||||
sign_in gestionnaire
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it 'dossier change is state for confirmed' do
|
it 'dossier change is state for validated' do
|
||||||
post :confirme, dossier_id: dossier_id
|
post :valid, dossier_id: dossier_id
|
||||||
|
|
||||||
dossier.reload
|
dossier.reload
|
||||||
expect(dossier.state).to eq('confirmed')
|
expect(dossier.state).to eq('validated')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'POST #close' do
|
||||||
|
before do
|
||||||
|
dossier.submitted!
|
||||||
|
sign_in gestionnaire
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'dossier change is state to closed' do
|
||||||
|
post :close, dossier_id: dossier_id
|
||||||
|
|
||||||
|
dossier.reload
|
||||||
|
expect(dossier.state).to eq('closed')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,10 +17,10 @@ describe Users::CommentairesController, type: :controller do
|
||||||
|
|
||||||
describe 'change dossier state after post a comment' do
|
describe 'change dossier state after post a comment' do
|
||||||
context 'when user is connected' do
|
context 'when user is connected' do
|
||||||
context 'when dossier is at state reply' do
|
context 'when dossier is at state replied' do
|
||||||
before do
|
before do
|
||||||
sign_in dossier.user
|
sign_in dossier.user
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
|
|
||||||
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
||||||
dossier.reload
|
dossier.reload
|
||||||
|
|
34
spec/controllers/root_controller_spec.rb
Normal file
34
spec/controllers/root_controller_spec.rb
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe RootController, type: :controller do
|
||||||
|
|
||||||
|
subject { get :index }
|
||||||
|
|
||||||
|
context 'when User is connected' do
|
||||||
|
before do
|
||||||
|
sign_in create(:user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(subject).to redirect_to(users_dossiers_path) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when Gestionnaire is connected' do
|
||||||
|
before do
|
||||||
|
sign_in create(:gestionnaire)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(subject).to redirect_to(backoffice_path) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when Administrateur is connected' do
|
||||||
|
before do
|
||||||
|
sign_in create(:administrateur)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(subject).to redirect_to(admin_procedures_path) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when nobody is connected' do
|
||||||
|
it { expect(subject).to redirect_to(new_user_session_path) }
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,10 +8,24 @@ RSpec.describe Users::CarteController, type: :controller do
|
||||||
let!(:etablissement) { create(:etablissement, dossier: dossier) }
|
let!(:etablissement) { create(:etablissement, dossier: dossier) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:bad_dossier_id) { Dossier.count + 1000 }
|
let(:bad_dossier_id) { Dossier.count + 1000 }
|
||||||
let(:ref_dossier_carto) { 'IATRQPQY' }
|
|
||||||
let(:adresse) { etablissement.adresse }
|
let(:adresse) { etablissement.adresse }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in dossier.user
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
|
context 'user is not connected' do
|
||||||
|
before do
|
||||||
|
sign_out dossier.user
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'redirects to users/sign_in' do
|
||||||
|
get :show, dossier_id: dossier_id
|
||||||
|
expect(response).to redirect_to('/users/sign_in')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :show, dossier_id: dossier_id
|
get :show, dossier_id: dossier_id
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
|
@ -19,22 +33,24 @@ RSpec.describe Users::CarteController, type: :controller do
|
||||||
|
|
||||||
it 'redirection vers la liste des dossiers du user si dossier ID n\'existe pas' do
|
it 'redirection vers la liste des dossiers du user si dossier ID n\'existe pas' do
|
||||||
get :show, dossier_id: bad_dossier_id
|
get :show, dossier_id: bad_dossier_id
|
||||||
expect(response).to redirect_to(controller: :dossiers, action: :index)
|
expect(response).to redirect_to(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like "not owner of dossier", :show
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #save_ref_api_carto' do
|
describe 'POST #save_ref_api_carto' do
|
||||||
context 'Aucune localisation n\'a jamais été enregistrée' do
|
context 'Aucune localisation n\'a jamais été enregistrée' do
|
||||||
it do
|
it do
|
||||||
post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier_carto: ref_dossier_carto
|
post :save_ref_api_carto, dossier_id: dossier_id
|
||||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/description")
|
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/description")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'En train de modifier la localisation' do
|
context 'En train de modifier la localisation' do
|
||||||
let(:dossier) { create(:dossier, :with_procedure, :with_user, ref_dossier_carto: ref_dossier_carto, state: 'proposed') }
|
let(:dossier) { create(:dossier, :with_procedure, :with_user, state: 'initiated') }
|
||||||
before do
|
before do
|
||||||
post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier_carto: ref_dossier_carto
|
post :save_ref_api_carto, dossier_id: dossier_id
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Enregistrement d\'un commentaire informant la modification' do
|
context 'Enregistrement d\'un commentaire informant la modification' do
|
||||||
|
@ -69,11 +85,11 @@ RSpec.describe Users::CarteController, type: :controller do
|
||||||
get :get_position, dossier_id: dossier.id
|
get :get_position, dossier_id: dossier.id
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { dossier.reload }
|
subject { JSON.parse(response.body) }
|
||||||
|
|
||||||
it 'on enregistre des coordonnées lat et lon à 0' do
|
it 'on enregistre des coordonnées lat et lon à 0' do
|
||||||
expect(subject.position_lat).to eq('0')
|
expect(subject['lat']).to eq('0')
|
||||||
expect(subject.position_lon).to eq('0')
|
expect(subject['lon']).to eq('0')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,22 @@ describe Users::DescriptionController, type: :controller do
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in dossier.user
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
|
context 'user is not connected' do
|
||||||
|
before do
|
||||||
|
sign_out dossier.user
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'redirects to users/sign_in' do
|
||||||
|
get :show, dossier_id: dossier_id
|
||||||
|
expect(response).to redirect_to('/users/sign_in')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :show, dossier_id: dossier_id
|
get :show, dossier_id: dossier_id
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
|
@ -14,17 +29,16 @@ describe Users::DescriptionController, type: :controller do
|
||||||
|
|
||||||
it 'redirection vers start si mauvais dossier ID' do
|
it 'redirection vers start si mauvais dossier ID' do
|
||||||
get :show, dossier_id: bad_dossier_id
|
get :show, dossier_id: bad_dossier_id
|
||||||
expect(response).to redirect_to(controller: :siret)
|
expect(response).to redirect_to(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like "not owner of dossier", :show
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
let(:timestamp) { Time.now }
|
let(:timestamp) { Time.now }
|
||||||
let(:nom_projet) { 'Projet de test' }
|
let(:nom_projet) { 'Projet de test' }
|
||||||
let(:description) { 'Description de test Coucou, je suis un saut à la ligne Je suis un double saut la ligne.' }
|
let(:description) { 'Description de test Coucou, je suis un saut à la ligne Je suis un double saut la ligne.' }
|
||||||
let(:montant_projet) { 12_000 }
|
|
||||||
let(:montant_aide_demande) { 3000 }
|
|
||||||
let(:date_previsionnelle) { '20/01/2016' }
|
|
||||||
|
|
||||||
let(:name_piece_justificative) { 'dossierPDF.pdf' }
|
let(:name_piece_justificative) { 'dossierPDF.pdf' }
|
||||||
let(:name_piece_justificative_0) { 'piece_justificative_0.pdf' }
|
let(:name_piece_justificative_0) { 'piece_justificative_0.pdf' }
|
||||||
|
@ -39,7 +53,7 @@ describe Users::DescriptionController, type: :controller do
|
||||||
describe 'Premier enregistrement des données' do
|
describe 'Premier enregistrement des données' do
|
||||||
before do
|
before do
|
||||||
dossier.draft!
|
dossier.draft!
|
||||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle
|
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,15 +62,15 @@ describe Users::DescriptionController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'etat du dossier est soumis' do
|
it 'etat du dossier est soumis' do
|
||||||
expect(dossier.state).to eq('proposed')
|
expect(dossier.state).to eq('initiated')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO changer les valeurs des champs et check in bdd
|
# TODO changer les valeurs des champs et check in bdd
|
||||||
context 'En train de manipuler un dossier non brouillon' do
|
context 'En train de manipuler un dossier non brouillon' do
|
||||||
before do
|
before do
|
||||||
dossier.proposed!
|
dossier.initiated!
|
||||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle
|
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,10 +105,7 @@ describe Users::DescriptionController, type: :controller do
|
||||||
post :create,
|
post :create,
|
||||||
dossier_id: dossier_id,
|
dossier_id: dossier_id,
|
||||||
nom_projet: nom_projet,
|
nom_projet: nom_projet,
|
||||||
description: description,
|
description: description
|
||||||
montant_projet: montant_projet,
|
|
||||||
montant_aide_demande: montant_aide_demande,
|
|
||||||
date_previsionnelle: date_previsionnelle
|
|
||||||
}
|
}
|
||||||
before { subject }
|
before { subject }
|
||||||
|
|
||||||
|
@ -109,34 +120,13 @@ describe Users::DescriptionController, type: :controller do
|
||||||
it { is_expected.to render_template(:show) }
|
it { is_expected.to render_template(:show) }
|
||||||
it { expect(flash[:alert]).to be_present }
|
it { expect(flash[:alert]).to be_present }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
context 'montant_projet empty' do
|
|
||||||
let(:montant_projet) { '' }
|
|
||||||
it { is_expected.to render_template(:show) }
|
|
||||||
it { expect(flash[:alert]).to be_present }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'montant_aide_demande empty' do
|
|
||||||
let(:montant_aide_demande) { '' }
|
|
||||||
it { is_expected.to render_template(:show) }
|
|
||||||
it { expect(flash[:alert]).to be_present }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'date_previsionnelle empty' do
|
|
||||||
let(:date_previsionnelle) { '' }
|
|
||||||
it { is_expected.to render_template(:show) }
|
|
||||||
it { expect(flash[:alert]).to be_present }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'Sauvegarde du CERFA PDF' do
|
context 'Sauvegarde du CERFA PDF' do
|
||||||
before do
|
before do
|
||||||
post :create, dossier_id: dossier_id,
|
post :create, dossier_id: dossier_id,
|
||||||
nom_projet: nom_projet,
|
nom_projet: nom_projet,
|
||||||
description: description,
|
description: description,
|
||||||
montant_projet: montant_projet,
|
|
||||||
montant_aide_demande: montant_aide_demande,
|
|
||||||
date_previsionnelle: date_previsionnelle,
|
|
||||||
cerfa_pdf: cerfa_pdf
|
cerfa_pdf: cerfa_pdf
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
@ -154,7 +144,7 @@ describe Users::DescriptionController, type: :controller do
|
||||||
|
|
||||||
context 'les anciens CERFA PDF sont écrasées à chaque fois' do
|
context 'les anciens CERFA PDF sont écrasées à chaque fois' do
|
||||||
it 'il n\'y a qu\'un CERFA PDF par dossier' do
|
it 'il n\'y a qu\'un CERFA PDF par dossier' do
|
||||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, cerfa_pdf: cerfa_pdf
|
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, cerfa_pdf: cerfa_pdf
|
||||||
cerfa = PieceJustificative.where(type_de_piece_justificative_id: '0', dossier_id: dossier_id)
|
cerfa = PieceJustificative.where(type_de_piece_justificative_id: '0', dossier_id: dossier_id)
|
||||||
expect(cerfa.many?).to eq(false)
|
expect(cerfa.many?).to eq(false)
|
||||||
end
|
end
|
||||||
|
@ -165,15 +155,35 @@ describe Users::DescriptionController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'Sauvegarde des champs' do
|
||||||
|
let(:champs_dossier) { dossier.champs }
|
||||||
|
let(:dossier_champs_first) { 'test value' }
|
||||||
|
before do
|
||||||
|
post :create, {dossier_id: dossier_id,
|
||||||
|
nom_projet: nom_projet,
|
||||||
|
description: description,
|
||||||
|
champs: {
|
||||||
|
"'#{dossier.champs.first.id}'" => dossier_champs_first
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dossier.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(dossier.champs.first.value).to eq(dossier_champs_first) }
|
||||||
|
|
||||||
|
context 'when champs value is empty' do
|
||||||
|
let(:dossier_champs_first) { 'test value' }
|
||||||
|
|
||||||
|
it { expect(dossier.champs.first.value).to eq(dossier_champs_first) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'Sauvegarde des pièces justificatives' do
|
context 'Sauvegarde des pièces justificatives' do
|
||||||
let(:all_pj_type){ dossier.procedure.type_de_piece_justificative_ids }
|
let(:all_pj_type){ dossier.procedure.type_de_piece_justificative_ids }
|
||||||
before do
|
before do
|
||||||
post :create, {dossier_id: dossier_id,
|
post :create, {dossier_id: dossier_id,
|
||||||
nom_projet: nom_projet,
|
nom_projet: nom_projet,
|
||||||
description: description,
|
description: description,
|
||||||
montant_projet: montant_projet,
|
|
||||||
montant_aide_demande: montant_aide_demande,
|
|
||||||
date_previsionnelle: date_previsionnelle,
|
|
||||||
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
|
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
|
||||||
'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
|
'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
|
||||||
dossier.reload
|
dossier.reload
|
|
@ -30,7 +30,7 @@ describe Users::DossiersController, type: :controller do
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
before do
|
before do
|
||||||
sign_in create(:user)
|
sign_in dossier.user
|
||||||
end
|
end
|
||||||
it 'returns http success with dossier_id valid' do
|
it 'returns http success with dossier_id valid' do
|
||||||
get :show, id: dossier_id
|
get :show, id: dossier_id
|
||||||
|
@ -130,7 +130,7 @@ describe Users::DossiersController, type: :controller do
|
||||||
|
|
||||||
describe 'PUT #update' do
|
describe 'PUT #update' do
|
||||||
before do
|
before do
|
||||||
sign_in create(:user)
|
sign_in dossier.user
|
||||||
put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
||||||
end
|
end
|
||||||
context 'when Checkbox is checked' do
|
context 'when Checkbox is checked' do
|
||||||
|
|
|
@ -16,40 +16,43 @@ describe Users::RecapitulatifController, type: :controller do
|
||||||
|
|
||||||
it 'redirection vers siret si mauvais dossier ID' do
|
it 'redirection vers siret si mauvais dossier ID' do
|
||||||
get :show, dossier_id: bad_dossier_id
|
get :show, dossier_id: bad_dossier_id
|
||||||
expect(response).to redirect_to('/users/siret')
|
expect(response).to redirect_to('/')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like "not owner of dossier", :show
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #propose' do
|
describe 'POST #initiate' do
|
||||||
context 'when an user propose his dossier' do
|
context 'when an user initiate his dossier' do
|
||||||
before do
|
before do
|
||||||
post :propose, dossier_id: dossier.id
|
post :initiate, dossier_id: dossier.id
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'dossier change his state for processed' do
|
it 'dossier change his state for closed' do
|
||||||
dossier.reload
|
dossier.reload
|
||||||
expect(dossier.state).to eq('proposed')
|
expect(dossier.state).to eq('initiated')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'a message informe user what his dossier is proposed' do
|
it 'a message informe user what his dossier is initiated' do
|
||||||
expect(flash[:notice]).to include('Dossier soumis avec succès.')
|
expect(flash[:notice]).to include('Dossier soumis avec succès.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #depose' do
|
describe 'POST #submit' do
|
||||||
context 'when an user depose his dossier' do
|
context 'when an user depose his dossier' do
|
||||||
before do
|
before do
|
||||||
dossier.confirmed!
|
dossier.validated!
|
||||||
post :depose, dossier_id: dossier.id
|
post :submit, dossier_id: dossier.id
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'dossier change his state for deposed' do
|
it 'dossier change his state for submitted' do
|
||||||
dossier.reload
|
dossier.reload
|
||||||
expect(dossier.state).to eq('deposited')
|
expect(dossier.state).to eq('submitted')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'a message informe user what his dossier is proposed' do
|
it 'a message informe user what his dossier is initiated' do
|
||||||
expect(flash[:notice]).to include('Dossier déposé avec succès.')
|
expect(flash[:notice]).to include('Dossier déposé avec succès.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
55
spec/controllers/users_controller_spec.rb
Normal file
55
spec/controllers/users_controller_spec.rb
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe UsersController, type: :controller do
|
||||||
|
|
||||||
|
describe '#current_user_dossier' do
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
let(:dossier) { create(:dossier, user: user)}
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in user
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when no dossier_id is filled' do
|
||||||
|
it { expect{ subject.current_user_dossier }.to raise_error }
|
||||||
|
end
|
||||||
|
|
||||||
|
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 incorrect' do
|
||||||
|
it { expect{ subject.current_user_dossier 1 }.to raise_error }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when no params[] is given' do
|
||||||
|
context 'when dossier id is valid' do
|
||||||
|
before do
|
||||||
|
subject.params[:dossier_id] = dossier.id
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns current user dossier' do
|
||||||
|
expect(subject.current_user_dossier).to eq(dossier)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier id is incorrect' do
|
||||||
|
it { expect{ subject.current_user_dossier }.to raise_error }
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -17,13 +17,13 @@ describe DossierDecorator do
|
||||||
expect(subject).to eq('Brouillon')
|
expect(subject).to eq('Brouillon')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'proposed is propose' do
|
it 'initiated is initiate' do
|
||||||
dossier.proposed!
|
dossier.initiated!
|
||||||
expect(subject).to eq('Soumis')
|
expect(subject).to eq('Soumis')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'reply is repondu' do
|
it 'replied is repondu' do
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
expect(subject).to eq('Répondu')
|
expect(subject).to eq('Répondu')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,18 +32,18 @@ describe DossierDecorator do
|
||||||
expect(subject).to eq('Mis à jour')
|
expect(subject).to eq('Mis à jour')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'confirmed is valide' do
|
it 'validated is valide' do
|
||||||
dossier.confirmed!
|
dossier.validated!
|
||||||
expect(subject).to eq('Validé')
|
expect(subject).to eq('Validé')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deposited is dépose' do
|
it 'submitted is dépose' do
|
||||||
dossier.deposited!
|
dossier.submitted!
|
||||||
expect(subject).to eq('Déposé')
|
expect(subject).to eq('Déposé')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'processed is traité' do
|
it 'closed is traité' do
|
||||||
dossier.processed!
|
dossier.closed!
|
||||||
expect(subject).to eq('Traité')
|
expect(subject).to eq('Traité')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
7
spec/factories/administrateur.rb
Normal file
7
spec/factories/administrateur.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
sequence(:administrateur_email) { |n| "plop#{n}@plop.com" }
|
||||||
|
factory :administrateur do
|
||||||
|
email { generate(:administrateur_email) }
|
||||||
|
password 'password'
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,6 +2,7 @@ FactoryGirl.define do
|
||||||
factory :dossier do
|
factory :dossier do
|
||||||
nom_projet "Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger"
|
nom_projet "Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger"
|
||||||
state 'draft'
|
state 'draft'
|
||||||
|
|
||||||
trait :with_entreprise do
|
trait :with_entreprise do
|
||||||
after(:build) do |dossier, _evaluator|
|
after(:build) do |dossier, _evaluator|
|
||||||
etablissement = create(:etablissement)
|
etablissement = create(:etablissement)
|
||||||
|
@ -13,7 +14,7 @@ FactoryGirl.define do
|
||||||
|
|
||||||
trait :with_procedure do
|
trait :with_procedure do
|
||||||
after(:build) do |dossier, _evaluator|
|
after(:build) do |dossier, _evaluator|
|
||||||
procedure = create(:procedure, :with_two_type_de_piece_justificative)
|
procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champs)
|
||||||
dossier.procedure = procedure
|
dossier.procedure = procedure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,14 @@ FactoryGirl.define do
|
||||||
libelle 'Demande de subvention'
|
libelle 'Demande de subvention'
|
||||||
description "Demande de subvention à l'intention des associations"
|
description "Demande de subvention à l'intention des associations"
|
||||||
|
|
||||||
|
trait :with_type_de_champs do
|
||||||
|
after(:build) do |procedure, _evaluator|
|
||||||
|
type_de_champs = create(:type_de_champs)
|
||||||
|
|
||||||
|
procedure.types_de_champs << type_de_champs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
trait :with_two_type_de_piece_justificative do
|
trait :with_two_type_de_piece_justificative do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
rib = create(:type_de_piece_justificative, :rib)
|
rib = create(:type_de_piece_justificative, :rib)
|
||||||
|
|
8
spec/factories/type_de_champs.rb
Normal file
8
spec/factories/type_de_champs.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :type_de_champs do
|
||||||
|
libelle 'Libellé'
|
||||||
|
description 'description de votre projet'
|
||||||
|
type_champs 'textarea'
|
||||||
|
order_place 1
|
||||||
|
end
|
||||||
|
end
|
77
spec/features/admin/add_type_de_champs_spec.rb
Normal file
77
spec/features/admin/add_type_de_champs_spec.rb
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'add a new type de champs', js: true do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrateur, scope: :administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when create a new procedure' do
|
||||||
|
before do
|
||||||
|
visit new_admin_procedure_path
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'page have form to created new type de champs' do
|
||||||
|
expect(page).to have_css('#type_de_champs_0')
|
||||||
|
expect(page).to have_css('input[name="type_de_champs[0][libelle]"]')
|
||||||
|
expect(page).to have_css('select[name="type_de_champs[0][type]"]')
|
||||||
|
expect(page).to have_css('textarea[name="type_de_champs[0][description]"]')
|
||||||
|
expect(page).to have_css('input[name="type_de_champs[0][order_place]"]', visible: false)
|
||||||
|
expect(page).to have_css('input[name="type_de_champs[0][id_type_de_champs]"]', visible: false)
|
||||||
|
expect(page).to have_css('input[name="type_de_champs[0][delete]"]', visible: false)
|
||||||
|
|
||||||
|
expect(page).to have_css('#order_type_de_champs_0_button', visible: false);
|
||||||
|
expect(page).to have_css('#order_type_de_champs_0_up_procedure', visible: false);
|
||||||
|
expect(page).to have_css('#order_type_de_champs_0_down_procedure', visible: false);
|
||||||
|
|
||||||
|
expect(page).to have_css('#new_type_de_champs #add_type_de_champs_button')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user add a new champs type' do
|
||||||
|
before do
|
||||||
|
page.find_by_id('type_de_champs_0').find_by_id('libelle').set 'Libelle de test'
|
||||||
|
page.find_by_id('type_de_champs_0').find_by_id('description').set 'Description de test'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'a new champs type line is appeared with increment index id' do
|
||||||
|
expect(page).to have_css('#type_de_champs_1')
|
||||||
|
expect(page).to have_css('input[name="type_de_champs[1][libelle]"]')
|
||||||
|
expect(page).to have_css('select[name="type_de_champs[1][type]"]')
|
||||||
|
expect(page).to have_css('textarea[name="type_de_champs[1][description]"]')
|
||||||
|
expect(page).to have_css('input[name="type_de_champs[1][order_place]"]', visible: false)
|
||||||
|
expect(page).to have_css('input[name="type_de_champs[1][id_type_de_champs]"]', visible: false)
|
||||||
|
expect(page).to have_css('input[name="type_de_champs[1][delete]"]', visible: false)
|
||||||
|
|
||||||
|
expect(page).to have_css('#order_type_de_champs_1_button', visible: false);
|
||||||
|
expect(page).to have_css('#order_type_de_champs_1_up_procedure', visible: false);
|
||||||
|
expect(page).to have_css('#order_type_de_champs_1_down_procedure', visible: false);
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'the first line is filled' do
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find_by_id('libelle').value).to eq('Libelle de test')
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find_by_id('description').value).to eq('Description de test')
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'the first line have new button delete' do
|
||||||
|
expect(page).to have_css('#delete_type_de_champs_0_button')
|
||||||
|
expect(page).to have_css('#delete_type_de_champs_0_procedure')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'the new line is empty' do
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find_by_id('libelle').value).to eq('')
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find_by_id('description').value).to eq('')
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('2')
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find_by_id('id_type_de_champs', visible: false).value).to eq('')
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find_by_id('delete', visible: false).value).to eq('false')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'the button Ajouter is at side new line' do
|
||||||
|
expect(page).to have_css('#new_type_de_champs #type_de_champs_1 #add_type_de_champs_button')
|
||||||
|
expect(page).not_to have_css('#type_de_champs_0 #add_type_de_champs_button')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
58
spec/features/admin/add_type_de_piece_justificative_spec.rb
Normal file
58
spec/features/admin/add_type_de_piece_justificative_spec.rb
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'add a new type de piece justificative', js: true do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrateur, scope: :administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when create a new procedure' do
|
||||||
|
before do
|
||||||
|
visit new_admin_procedure_path
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'page have form to created new type de piece justificative' do
|
||||||
|
expect(page).to have_css('#type_de_piece_justificative_0')
|
||||||
|
expect(page).to have_css('input[name="type_de_piece_justificative[0][libelle]"]')
|
||||||
|
expect(page).to have_css('textarea[name="type_de_piece_justificative[0][description]"]')
|
||||||
|
expect(page).to have_css('input[name="type_de_piece_justificative[0][id_type_de_piece_justificative]"]', visible: false)
|
||||||
|
expect(page).to have_css('input[name="type_de_piece_justificative[0][delete]"]', visible: false)
|
||||||
|
|
||||||
|
expect(page).to have_css('#new_type_de_piece_justificative #add_type_de_piece_justificative_button')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user add a new piece justificative type' do
|
||||||
|
before do
|
||||||
|
page.find_by_id('type_de_piece_justificative_0').find_by_id('libelle').set 'Libelle de test'
|
||||||
|
page.find_by_id('type_de_piece_justificative_0').find_by_id('description').set 'Description de test'
|
||||||
|
page.click_on 'add_type_de_piece_justificative_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'a new piece justificative type line is appeared with increment index id' do
|
||||||
|
expect(page).to have_css('#type_de_piece_justificative_1')
|
||||||
|
expect(page).to have_css('input[name="type_de_piece_justificative[1][libelle]"]')
|
||||||
|
expect(page).to have_css('textarea[name="type_de_piece_justificative[1][description]"]')
|
||||||
|
expect(page).to have_css('input[name="type_de_piece_justificative[1][id_type_de_piece_justificative]"]', visible: false)
|
||||||
|
expect(page).to have_css('input[name="type_de_piece_justificative[1][delete]"]', visible: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'the first line is filled' do
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_0').find_by_id('libelle').value).to eq('Libelle de test')
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_0').find_by_id('description').value).to eq('Description de test')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'the new line is empty' do
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_1').find_by_id('libelle').value).to eq('')
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_1').find_by_id('description').value).to eq('')
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_1').find_by_id('id_type_de_piece_justificative', visible: false).value).to eq('')
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_1').find_by_id('delete', visible: false).value).to eq('false')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'the button Ajouter is at side new line' do
|
||||||
|
expect(page).to have_css('#new_type_de_piece_justificative #type_de_piece_justificative_1 #add_type_de_piece_justificative_button')
|
||||||
|
expect(page).not_to have_css('#type_de_piece_justificative_0 #add_type_de_piece_justificative_button')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
125
spec/features/admin/config_up_and_down_button_spec.rb
Normal file
125
spec/features/admin/config_up_and_down_button_spec.rb
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'config up and down button display', js: true do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrateur, scope: :administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have not type de champs' do
|
||||||
|
let!(:procedure) { create(:procedure) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_0 have not up and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have one type de champs' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_0 have not up and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_1 have not up and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_1_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_1_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have two type de champs' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs) }
|
||||||
|
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_0 have not up visible and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_down_procedure').visible?).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_1 have up button visible and down button not visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_1_up_procedure').visible?).to be_truthy
|
||||||
|
expect(page.find_by_id('order_type_de_champs_1_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_2 have not up and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_2_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_2_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have two type de champs into database and one type de champs add to form' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs) }
|
||||||
|
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_0 have not up visible and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_down_procedure').visible?).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_1 have up button and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_1_up_procedure').visible?).to be_truthy
|
||||||
|
expect(page.find_by_id('order_type_de_champs_1_down_procedure').visible?).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_2 have up visible and down button not visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_2_up_procedure').visible?).to be_truthy
|
||||||
|
expect(page.find_by_id('order_type_de_champs_2_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_3 have not up and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_3_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_3_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have two type de champs into database and one type de champs add to form and delete one type_de_champs' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs) }
|
||||||
|
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'delete_type_de_champs_2_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_0 have not up visible and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_0_down_procedure').visible?).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_1 have up button visible and down button not visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_1_up_procedure').visible?).to be_truthy
|
||||||
|
expect(page.find_by_id('order_type_de_champs_1_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_2 have up and down button not visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_2_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_2_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_3 have not up and down button visible' do
|
||||||
|
expect(page.find_by_id('order_type_de_champs_3_up_procedure', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('order_type_de_champs_3_down_procedure', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
80
spec/features/admin/delete_type_de_champs_spec.rb
Normal file
80
spec/features/admin/delete_type_de_champs_spec.rb
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'delete a type de champs form', js: true do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrateur, scope: :administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user click on type de trash button' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user edit a type de champs already save in database' do
|
||||||
|
let(:type_de_champs) { procedure.types_de_champs.first }
|
||||||
|
|
||||||
|
before do
|
||||||
|
page.click_on 'delete_type_de_champs_0_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'form is mask for the user' do
|
||||||
|
expect(page.find_by_id('type_de_champs_0', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'delete attribut of type de champs is turn to true' do
|
||||||
|
expect(page.find_by_id('type_de_champs_0', visible: false).find_by_id('delete', visible: false).value).to eq('true')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'attribut node is to move into div liste_delete_champs' do
|
||||||
|
expect(page).to have_css('#liste_delete_champs #type_de_champs_0', visible: false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user edit a type de champs just add on the form page' do
|
||||||
|
before do
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'delete_type_de_champs_1_procedure'
|
||||||
|
page.click_on 'delete_type_de_champs_2_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'form is mask for the user' do
|
||||||
|
expect(page.find_by_id('type_de_champs_1', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('type_de_champs_2', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'delete attribut of type de champs is turn to true' do
|
||||||
|
expect(page.find_by_id('type_de_champs_1', visible: false).find_by_id('delete', visible: false).value).to eq('true')
|
||||||
|
expect(page.find_by_id('type_de_champs_2', visible: false).find_by_id('delete', visible: false).value).to eq('true')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'attribut node is to move into div liste_delete_champs' do
|
||||||
|
expect(page).to have_css('#liste_delete_champs #type_de_champs_1', visible: false)
|
||||||
|
expect(page).to have_css('#liste_delete_champs #type_de_champs_2', visible: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'order_place type_de_champs_0_procedure is 1' do
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find("input[class='order_place']", visible: false).value).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'order_place type_de_champs_3_procedure is 2' do
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find("input[class='order_place']", visible: false).value).to eq('2')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'order_place type_de_champs_4_procedure is 3' do
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find("input[class='order_place']", visible: false).value).to eq('3')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'order_place type_de_champs_5_procedure is 4' do
|
||||||
|
expect(page.find_by_id('type_de_champs_5').find("input[class='order_place']", visible: false).value).to eq('4')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,52 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'delete a type de piece_justificative form', js: true do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrateur, scope: :administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user click on type de piece_justificative red X button' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user edit a type de piece_justificative already save in database' do
|
||||||
|
let(:type_de_piece_justificative) { procedure.types_de_piece_justificative.first }
|
||||||
|
|
||||||
|
before do
|
||||||
|
page.click_on 'delete_type_de_piece_justificative_0_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'form is mask for the user' do
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_0', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'delete attribut of type de piece_justificative is turn to true' do
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_0', visible: false).find_by_id('delete', visible: false).value).to eq('true')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user edit a type de piece_justificative just add on the form page' do
|
||||||
|
before do
|
||||||
|
page.click_on 'add_type_de_piece_justificative_procedure'
|
||||||
|
page.click_on 'add_type_de_piece_justificative_procedure'
|
||||||
|
page.click_on 'delete_type_de_piece_justificative_2_procedure'
|
||||||
|
page.click_on 'delete_type_de_piece_justificative_3_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'form is mask for the user' do
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_2', visible: false).visible?).to be_falsey
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_3', visible: false).visible?).to be_falsey
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'delete attribut of type de piece_justificative is turn to true' do
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_2', visible: false).find_by_id('delete', visible: false).value).to eq('true')
|
||||||
|
expect(page.find_by_id('type_de_piece_justificative_3', visible: false).find_by_id('delete', visible: false).value).to eq('true')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
79
spec/features/admin/move_down_type_de_champs_spec.rb
Normal file
79
spec/features/admin/move_down_type_de_champs_spec.rb
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'move down button type de champs', js: true do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrateur, scope: :administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when click on move down type de champs button' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs) }
|
||||||
|
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have two type de champs' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_0_down_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'it inverse the twice type de champs' do
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||||
|
before do
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when to click on down_button type_de_champs_1' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_1_down_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_1 and type_de_champs_2 is reversed' do
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when to click on up_button type_de_champs_3' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_3_down_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_3 and type_de_champs_4 is reversed' do
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when to click on up_button type_de_champs_0' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_0_down_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_0 and type_de_champs_2 is reversed' do
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
72
spec/features/admin/move_up_and_down_type_de_champs_spec.rb
Normal file
72
spec/features/admin/move_up_and_down_type_de_champs_spec.rb
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'move up and down button type de champs', js: true do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrateur, scope: :administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when click on move up and down type de champs button' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs) }
|
||||||
|
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||||
|
before do
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
end
|
||||||
|
#
|
||||||
|
context 'when to click on up_button type_de_champs_1 and down_button type_de_champs_0' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_1_up_procedure'
|
||||||
|
page.click_on 'order_type_de_champs_0_down_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_0 is at order place 3 and type_de_champs_1 is at order place 1 ' do
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when to click on down_button type_de_champs_3 and up_button type_de_champs_4' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_3_down_procedure'
|
||||||
|
page.click_on 'order_type_de_champs_4_up_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_2 and type_de_champs_3 is reversed' do
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when to click on up_button type_de_champs_2 and down_button type_de_champs_0 and up_button type_de_champs_4' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_2_up_procedure'
|
||||||
|
page.click_on 'order_type_de_champs_0_down_procedure'
|
||||||
|
page.click_on 'order_type_de_champs_4_up_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_2 and type_de_champs_4 is reversed' do
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
80
spec/features/admin/move_up_type_de_champs_spec.rb
Normal file
80
spec/features/admin/move_up_type_de_champs_spec.rb
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'move up button type de champs', js: true do
|
||||||
|
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrateur, scope: :administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when click on move up type de champs button' do
|
||||||
|
let!(:procedure) { create(:procedure, :with_type_de_champs) }
|
||||||
|
let!(:type_de_champs) { create(:type_de_champs, procedure: procedure, order_place: 2) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit admin_procedure_path id: procedure.id
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have two type de champs' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_1_up_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'it inverse the twice type de champs' do
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure have two type de champs in database and 3 type de champs add on the page' do
|
||||||
|
before do
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
page.click_on 'add_type_de_champs_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when to click on up_button type_de_champs_1' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_1_up_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_0 and type_de_champs_1 is reversed' do
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when to click on up_button type_de_champs_3' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_3_up_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_2 and type_de_champs_3 is reversed' do
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when to click on up_button type_de_champs_4' do
|
||||||
|
before do
|
||||||
|
page.click_on 'order_type_de_champs_4_up_procedure'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'type_de_champs_2 and type_de_champs_4 is reversed' do
|
||||||
|
expect(page.find_by_id('type_de_champs_1').find('input[class="order_place"]', visible: false).value).to eq('1');
|
||||||
|
expect(page.find_by_id('type_de_champs_0').find('input[class="order_place"]', visible: false).value).to eq('2');
|
||||||
|
expect(page.find_by_id('type_de_champs_3').find('input[class="order_place"]', visible: false).value).to eq('3');
|
||||||
|
expect(page.find_by_id('type_de_champs_4').find('input[class="order_place"]', visible: false).value).to eq('4');
|
||||||
|
expect(page.find_by_id('type_de_champs_2').find('input[class="order_place"]', visible: false).value).to eq('5');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature 'on backoffice page' do
|
feature 'on backoffice page' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let!(:dossier) { create(:dossier, :with_user, :with_entreprise, procedure: procedure, state: 'reply') }
|
let!(:dossier) { create(:dossier, :with_user, :with_entreprise, procedure: procedure, state: 'replied') }
|
||||||
before do
|
before do
|
||||||
visit backoffice_path
|
visit backoffice_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'On the description page' do
|
|
||||||
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
|
|
||||||
before do
|
|
||||||
visit users_dossier_description_path dossier
|
|
||||||
end
|
|
||||||
scenario 'date_previsionnelle field is present' do
|
|
||||||
expect(page).to have_css('#date_previsionnelle')
|
|
||||||
end
|
|
||||||
context 'when user clic on date_previsionnelle field', js: true do
|
|
||||||
before do
|
|
||||||
find_by_id('date_previsionnelle').click
|
|
||||||
end
|
|
||||||
scenario 'the datepicker popup is displayed' do
|
|
||||||
expect(page).to have_css('.datepicker-days')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -4,6 +4,13 @@ feature 'user is on description page' do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
|
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
|
||||||
before do
|
before do
|
||||||
visit users_dossier_description_path dossier
|
visit users_dossier_description_path dossier
|
||||||
|
|
||||||
|
within('#new_user') do
|
||||||
|
page.find_by_id('user_email').set dossier.user.email
|
||||||
|
page.find_by_id('user_password').set dossier.user.password
|
||||||
|
page.click_on 'Se connecter'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
it { expect(page).to have_css('#description_page') }
|
it { expect(page).to have_css('#description_page') }
|
||||||
|
|
||||||
|
@ -11,9 +18,6 @@ feature 'user is on description page' do
|
||||||
before do
|
before do
|
||||||
find_by_id('nom_projet').set 'mon nom'
|
find_by_id('nom_projet').set 'mon nom'
|
||||||
find_by_id('description').set 'ma description'
|
find_by_id('description').set 'ma description'
|
||||||
find_by_id('montant_projet').set 10_000
|
|
||||||
find_by_id('montant_aide_demande').set 100
|
|
||||||
find_by_id('date_previsionnelle').set '10/10/2010'
|
|
||||||
end
|
end
|
||||||
context 'before submit' do
|
context 'before submit' do
|
||||||
it 'dossier cerfa is empty' do
|
it 'dossier cerfa is empty' do
|
||||||
|
|
|
@ -49,9 +49,6 @@ feature 'user path for dossier creation' do
|
||||||
before do
|
before do
|
||||||
page.find_by_id('nom_projet').set 'Mon super projet'
|
page.find_by_id('nom_projet').set 'Mon super projet'
|
||||||
page.find_by_id('description').set 'Ma super description'
|
page.find_by_id('description').set 'Ma super description'
|
||||||
page.find_by_id('montant_projet').set 10_000
|
|
||||||
page.find_by_id('montant_aide_demande').set 1_000
|
|
||||||
page.find_by_id('date_previsionnelle').set '09/09/2015'
|
|
||||||
page.click_on 'Soumettre mon dossier'
|
page.click_on 'Soumettre mon dossier'
|
||||||
end
|
end
|
||||||
scenario 'user is on recap page' do
|
scenario 'user is on recap page' do
|
||||||
|
|
18
spec/models/administrateur_spec.rb
Normal file
18
spec/models/administrateur_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Administrateur, type: :model do
|
||||||
|
describe 'database column' do
|
||||||
|
it { is_expected.to have_db_column(:email) }
|
||||||
|
it { is_expected.to have_db_column(:encrypted_password) }
|
||||||
|
it { is_expected.to have_db_column(:reset_password_token) }
|
||||||
|
it { is_expected.to have_db_column(:reset_password_sent_at) }
|
||||||
|
it { is_expected.to have_db_column(:remember_created_at) }
|
||||||
|
it { is_expected.to have_db_column(:sign_in_count) }
|
||||||
|
it { is_expected.to have_db_column(:current_sign_in_at) }
|
||||||
|
it { is_expected.to have_db_column(:last_sign_in_at) }
|
||||||
|
it { is_expected.to have_db_column(:current_sign_in_ip) }
|
||||||
|
it { is_expected.to have_db_column(:last_sign_in_ip) }
|
||||||
|
it { is_expected.to have_db_column(:created_at) }
|
||||||
|
it { is_expected.to have_db_column(:updated_at) }
|
||||||
|
end
|
||||||
|
end
|
18
spec/models/champ_spec.rb
Normal file
18
spec/models/champ_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Champ do
|
||||||
|
describe 'database columns' do
|
||||||
|
it { is_expected.to have_db_column(:value) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'associations' do
|
||||||
|
it { is_expected.to belong_to(:dossier) }
|
||||||
|
it { is_expected.to belong_to(:type_de_champs) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'delegation' do
|
||||||
|
it { is_expected.to delegate_method(:libelle).to(:type_de_champs) }
|
||||||
|
it { is_expected.to delegate_method(:type_champs).to(:type_de_champs) }
|
||||||
|
it { is_expected.to delegate_method(:order_place).to(:type_de_champs) }
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,19 +5,18 @@ describe Dossier do
|
||||||
describe 'database columns' do
|
describe 'database columns' do
|
||||||
it { is_expected.to have_db_column(:description) }
|
it { is_expected.to have_db_column(:description) }
|
||||||
it { is_expected.to have_db_column(:autorisation_donnees) }
|
it { is_expected.to have_db_column(:autorisation_donnees) }
|
||||||
it { is_expected.to have_db_column(:position_lat) }
|
|
||||||
it { is_expected.to have_db_column(:position_lon) }
|
|
||||||
it { is_expected.to have_db_column(:nom_projet) }
|
it { is_expected.to have_db_column(:nom_projet) }
|
||||||
it { is_expected.to have_db_column(:montant_projet) }
|
|
||||||
it { is_expected.to have_db_column(:montant_aide_demande) }
|
|
||||||
it { is_expected.to have_db_column(:date_previsionnelle).of_type(:date) }
|
|
||||||
it { is_expected.to have_db_column(:created_at) }
|
it { is_expected.to have_db_column(:created_at) }
|
||||||
it { is_expected.to have_db_column(:updated_at) }
|
it { is_expected.to have_db_column(:updated_at) }
|
||||||
|
it { is_expected.to have_db_column(:state) }
|
||||||
|
it { is_expected.to have_db_column(:procedure_id) }
|
||||||
|
it { is_expected.to have_db_column(:user_id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'associations' do
|
describe 'associations' do
|
||||||
it { is_expected.to belong_to(:procedure) }
|
it { is_expected.to belong_to(:procedure) }
|
||||||
it { is_expected.to have_many(:pieces_justificatives) }
|
it { is_expected.to have_many(:pieces_justificatives) }
|
||||||
|
it { is_expected.to have_many(:champs) }
|
||||||
it { is_expected.to have_many(:commentaires) }
|
it { is_expected.to have_many(:commentaires) }
|
||||||
it { is_expected.to have_one(:cerfa) }
|
it { is_expected.to have_one(:cerfa) }
|
||||||
it { is_expected.to have_one(:etablissement) }
|
it { is_expected.to have_one(:etablissement) }
|
||||||
|
@ -29,6 +28,7 @@ describe Dossier do
|
||||||
it { is_expected.to delegate_method(:siren).to(:entreprise) }
|
it { is_expected.to delegate_method(:siren).to(:entreprise) }
|
||||||
it { is_expected.to delegate_method(:siret).to(:etablissement) }
|
it { is_expected.to delegate_method(:siret).to(:etablissement) }
|
||||||
it { is_expected.to delegate_method(:types_de_piece_justificative).to(:procedure) }
|
it { is_expected.to delegate_method(:types_de_piece_justificative).to(:procedure) }
|
||||||
|
it { is_expected.to delegate_method(:types_de_champs).to(:procedure) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'validation' do
|
describe 'validation' do
|
||||||
|
@ -42,16 +42,6 @@ describe Dossier do
|
||||||
it { is_expected.not_to allow_value('').for(:description) }
|
it { is_expected.not_to allow_value('').for(:description) }
|
||||||
it { is_expected.to allow_value('ma superbe description').for(:description) }
|
it { is_expected.to allow_value('ma superbe description').for(:description) }
|
||||||
end
|
end
|
||||||
context 'montant_projet' do
|
|
||||||
it { is_expected.to allow_value(nil).for(:montant_projet) }
|
|
||||||
it { is_expected.not_to allow_value('').for(:montant_projet) }
|
|
||||||
it { is_expected.to allow_value(124324).for(:montant_projet) }
|
|
||||||
end
|
|
||||||
context 'montant_aide_demande' do
|
|
||||||
it { is_expected.to allow_value(nil).for(:montant_aide_demande) }
|
|
||||||
it { is_expected.not_to allow_value('').for(:montant_aide_demande) }
|
|
||||||
it { is_expected.to allow_value(124324).for(:montant_aide_demande) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'methods' do
|
describe 'methods' do
|
||||||
|
@ -102,12 +92,27 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#build_default_champs' do
|
||||||
|
context 'when dossier is linked to a procedure' do
|
||||||
|
let(:dossier) { create(:dossier, :with_procedure, user: user) }
|
||||||
|
it 'build all champs needed' do
|
||||||
|
expect(dossier.champs.count).to eq(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#save' do
|
describe '#save' do
|
||||||
subject { create(:dossier, procedure_id: nil, user: user) }
|
subject { create(:dossier, procedure_id: nil, user: user) }
|
||||||
|
let!(:procedure) { create(:procedure) }
|
||||||
context 'when is linked to a procedure' do
|
context 'when is linked to a procedure' do
|
||||||
it 'creates default pieces justificatives' do
|
it 'creates default pieces justificatives' do
|
||||||
expect(subject).to receive(:build_default_pieces_justificatives)
|
expect(subject).to receive(:build_default_pieces_justificatives)
|
||||||
subject.update_attributes(procedure_id: 1)
|
subject.update_attributes(procedure_id: procedure.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates default champs' do
|
||||||
|
expect(subject).to receive(:build_default_champs)
|
||||||
|
subject.update_attributes(procedure_id: procedure.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'when is not linked to a procedure' do
|
context 'when is not linked to a procedure' do
|
||||||
|
@ -115,14 +120,18 @@ describe Dossier do
|
||||||
expect(subject).not_to receive(:build_default_pieces_justificatives)
|
expect(subject).not_to receive(:build_default_pieces_justificatives)
|
||||||
subject.update_attributes(description: 'plop')
|
subject.update_attributes(description: 'plop')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not create default champs' do
|
||||||
|
expect(subject).not_to receive(:build_default_champs)
|
||||||
|
subject.update_attributes(description: 'plop')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO revoir le nommage
|
|
||||||
describe '#next_step' do
|
describe '#next_step' do
|
||||||
let(:dossier) { create(:dossier, :with_user) }
|
let(:dossier) { create(:dossier, :with_user) }
|
||||||
let(:role) { 'user' }
|
let(:role) { 'user' }
|
||||||
let(:action) { 'propose' }
|
let(:action) { 'initiate' }
|
||||||
|
|
||||||
subject { dossier.next_step! role, action }
|
subject { dossier.next_step! role, action }
|
||||||
|
|
||||||
|
@ -156,17 +165,17 @@ describe Dossier do
|
||||||
it { is_expected.to eq('draft') }
|
it { is_expected.to eq('draft') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when he proposes a dossier' do
|
context 'when he initiate a dossier' do
|
||||||
let(:action) { 'propose' }
|
let(:action) { 'initiate' }
|
||||||
|
|
||||||
it { is_expected.to eq('proposed') }
|
it { is_expected.to eq('initiated') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier is at state proposed' do
|
context 'when dossier is at state initiated' do
|
||||||
before do
|
before do
|
||||||
dossier.proposed!
|
dossier.initiated!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is connect' do
|
context 'when user is connect' do
|
||||||
|
@ -175,13 +184,13 @@ describe Dossier do
|
||||||
context 'when is update dossier informations' do
|
context 'when is update dossier informations' do
|
||||||
let(:action) { 'update' }
|
let(:action) { 'update' }
|
||||||
|
|
||||||
it {is_expected.to eq('proposed')}
|
it {is_expected.to eq('initiated')}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it {is_expected.to eq('proposed')}
|
it {is_expected.to eq('initiated')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -191,20 +200,20 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('reply')}
|
it { is_expected.to eq('replied')}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is confirmed the dossier' do
|
context 'when is validated the dossier' do
|
||||||
let(:action) { 'confirme' }
|
let(:action) { 'valid' }
|
||||||
|
|
||||||
it {is_expected.to eq('confirmed')}
|
it {is_expected.to eq('validated')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier is at state reply' do
|
context 'when dossier is at state replied' do
|
||||||
before do
|
before do
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is connect' do
|
context 'when user is connect' do
|
||||||
|
@ -232,13 +241,13 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('reply')}
|
it { is_expected.to eq('replied')}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is confirmed the dossier' do
|
context 'when is validated the dossier' do
|
||||||
let(:action) { 'confirme' }
|
let(:action) { 'valid' }
|
||||||
|
|
||||||
it {is_expected.to eq('confirmed')}
|
it {is_expected.to eq('validated')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -270,20 +279,20 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('reply')}
|
it { is_expected.to eq('replied')}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is confirmed the dossier' do
|
context 'when is validated the dossier' do
|
||||||
let(:action) { 'confirme' }
|
let(:action) { 'valid' }
|
||||||
|
|
||||||
it {is_expected.to eq('confirmed')}
|
it {is_expected.to eq('validated')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier is at state confirmed' do
|
context 'when dossier is at state validated' do
|
||||||
before do
|
before do
|
||||||
dossier.confirmed!
|
dossier.validated!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is connect' do
|
context 'when user is connect' do
|
||||||
|
@ -291,13 +300,13 @@ describe Dossier do
|
||||||
|
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
it { is_expected.to eq('confirmed') }
|
it { is_expected.to eq('validated') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is deposed the dossier' do
|
context 'when is submitted the dossier' do
|
||||||
let(:action) { 'depose' }
|
let(:action) { 'submit' }
|
||||||
|
|
||||||
it { is_expected.to eq('deposited') }
|
it { is_expected.to eq('submitted') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -307,14 +316,14 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('confirmed')}
|
it { is_expected.to eq('validated')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier is at state deposited' do
|
context 'when dossier is at state submitted' do
|
||||||
before do
|
before do
|
||||||
dossier.deposited!
|
dossier.submitted!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is connect' do
|
context 'when user is connect' do
|
||||||
|
@ -323,7 +332,7 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('deposited') }
|
it { is_expected.to eq('submitted') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -333,20 +342,20 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it {is_expected.to eq('deposited')}
|
it {is_expected.to eq('submitted')}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is processed the dossier' do
|
context 'when is closed the dossier' do
|
||||||
let(:action) { 'process' }
|
let(:action) { 'close' }
|
||||||
|
|
||||||
it {is_expected.to eq('processed')}
|
it {is_expected.to eq('closed')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier is at state processed' do
|
context 'when dossier is at state closed' do
|
||||||
before do
|
before do
|
||||||
dossier.processed!
|
dossier.closed!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is connect' do
|
context 'when user is connect' do
|
||||||
|
@ -355,7 +364,7 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('processed')}
|
it { is_expected.to eq('closed')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -365,7 +374,7 @@ describe Dossier do
|
||||||
context 'when is post a comment' do
|
context 'when is post a comment' do
|
||||||
let(:action) { 'comment' }
|
let(:action) { 'comment' }
|
||||||
|
|
||||||
it { is_expected.to eq('processed')}
|
it { is_expected.to eq('closed')}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -373,13 +382,13 @@ describe Dossier do
|
||||||
|
|
||||||
context 'gestionnaire backoffice methods' do
|
context 'gestionnaire backoffice methods' do
|
||||||
let!(:dossier1) { create(:dossier, :with_user, :with_procedure, state: 'draft')}
|
let!(:dossier1) { create(:dossier, :with_user, :with_procedure, state: 'draft')}
|
||||||
let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'proposed')}
|
let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'initiated')}
|
||||||
let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'proposed')}
|
let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'initiated')}
|
||||||
let!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'reply')}
|
let!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'replied')}
|
||||||
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
|
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
|
||||||
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'confirmed')}
|
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'validated')}
|
||||||
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}
|
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'submitted')}
|
||||||
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'processed')}
|
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'closed')}
|
||||||
|
|
||||||
describe '#a_traiter' do
|
describe '#a_traiter' do
|
||||||
subject { described_class.a_traiter }
|
subject { described_class.a_traiter }
|
||||||
|
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
||||||
describe Procedure do
|
describe Procedure do
|
||||||
describe 'assocations' do
|
describe 'assocations' do
|
||||||
it { is_expected.to have_many(:types_de_piece_justificative) }
|
it { is_expected.to have_many(:types_de_piece_justificative) }
|
||||||
|
it { is_expected.to have_many(:types_de_champs) }
|
||||||
it { is_expected.to have_many(:dossiers) }
|
it { is_expected.to have_many(:dossiers) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,8 +29,8 @@ describe Procedure do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'lien_demarche' do
|
context 'lien_demarche' do
|
||||||
it { is_expected.not_to allow_value(nil).for(:lien_demarche) }
|
it { is_expected.to allow_value(nil).for(:lien_demarche) }
|
||||||
it { is_expected.not_to allow_value('').for(:lien_demarche) }
|
it { is_expected.to allow_value('').for(:lien_demarche) }
|
||||||
it { is_expected.to allow_value('http://localhost').for(:lien_demarche) }
|
it { is_expected.to allow_value('http://localhost').for(:lien_demarche) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
45
spec/models/type_de_champs_spec.rb
Normal file
45
spec/models/type_de_champs_spec.rb
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe TypeDeChamps do
|
||||||
|
describe 'database columns' do
|
||||||
|
it { is_expected.to have_db_column(:libelle) }
|
||||||
|
it { is_expected.to have_db_column(:type_champs) }
|
||||||
|
it { is_expected.to have_db_column(:order_place) }
|
||||||
|
it { is_expected.to have_db_column(:description) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'associations' do
|
||||||
|
it { is_expected.to belong_to(:procedure) }
|
||||||
|
it { is_expected.to have_many(:champ) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'validation' do
|
||||||
|
context 'libelle' do
|
||||||
|
it { is_expected.not_to allow_value(nil).for(:libelle) }
|
||||||
|
it { is_expected.not_to allow_value('').for(:libelle) }
|
||||||
|
it { is_expected.to allow_value('Montant projet').for(:libelle) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'type' do
|
||||||
|
it { is_expected.not_to allow_value(nil).for(:type_champs) }
|
||||||
|
it { is_expected.not_to allow_value('').for(:type_champs) }
|
||||||
|
|
||||||
|
it { is_expected.to allow_value('text').for(:type_champs) }
|
||||||
|
it { is_expected.to allow_value('textarea').for(:type_champs) }
|
||||||
|
it { is_expected.to allow_value('datetime').for(:type_champs) }
|
||||||
|
it { is_expected.to allow_value('number').for(:type_champs) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'order_place' do
|
||||||
|
it { is_expected.not_to allow_value(nil).for(:order_place) }
|
||||||
|
it { is_expected.not_to allow_value('').for(:order_place) }
|
||||||
|
it { is_expected.to allow_value(1).for(:order_place) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'description' do
|
||||||
|
it { is_expected.to allow_value(nil).for(:description) }
|
||||||
|
it { is_expected.to allow_value('').for(:description) }
|
||||||
|
it { is_expected.to allow_value('blabla').for(:description) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
17
spec/support/shared_exemples_for_dossier.rb
Normal file
17
spec/support/shared_exemples_for_dossier.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
RSpec.shared_examples 'not owner of dossier' do |controller, redirect|
|
||||||
|
let(:dossier_2) { create(:dossier, :with_user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
get controller, dossier_id: dossier_2.id
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'redirect to home page' do
|
||||||
|
expect(response).to redirect_to(redirect || '/')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'show a flash message error' do
|
||||||
|
expect(flash[:alert]).to be_present
|
||||||
|
end
|
||||||
|
end
|
|
@ -14,62 +14,62 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||||
assign(:commentaires, dossier.commentaires)
|
assign(:commentaires, dossier.commentaires)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'sur la rendered admin du dossier' do
|
context 'on the dossier admin page' do
|
||||||
before do
|
before do
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
it 'la section infos entreprise est présente' do
|
it 'enterprise informations are present' do
|
||||||
expect(rendered).to have_selector('#infos_entreprise')
|
expect(rendered).to have_selector('#infos_entreprise')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'la section infos dossier est présente' do
|
it 'dossier informations are present' do
|
||||||
expect(rendered).to have_selector('#infos_dossier')
|
expect(rendered).to have_selector('#infos_dossier')
|
||||||
end
|
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_selector('#dossier_id')
|
||||||
expect(rendered).to have_content(dossier_id)
|
expect(rendered).to have_content(dossier_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'les liens de modifications sont non présent' do
|
context 'edit link are present' do
|
||||||
it 'le lien vers carte' do
|
it 'edit carto' do
|
||||||
expect(rendered).to_not have_selector('a[id=modif_carte]')
|
expect(rendered).to_not have_selector('a[id=modif_carte]')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'le lien vers description' do
|
it 'edit description' do
|
||||||
expect(rendered).to_not have_selector('a[id=modif_description]')
|
expect(rendered).to_not have_selector('a[id=modif_description]')
|
||||||
end
|
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')
|
expect(rendered).to_not have_css('#maj_infos')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'gestion des etats du dossier' do
|
context 'dossier state changements' do
|
||||||
context 'when dossier have state proposed' do
|
context 'when dossier have state initiated' do
|
||||||
before do
|
before do
|
||||||
dossier.proposed!
|
dossier.initiated!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Soumis') }
|
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_css('#action_button')
|
||||||
expect(rendered).to have_content('Valider le dossier')
|
expect(rendered).to have_content('Valider le dossier')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state reply' do
|
context 'when dossier have state replied' do
|
||||||
before do
|
before do
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Répondu') }
|
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_css('#action_button')
|
||||||
expect(rendered).to have_content('Valider le dossier')
|
expect(rendered).to have_content('Valider le dossier')
|
||||||
end
|
end
|
||||||
|
@ -83,102 +83,106 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Mis à jour') }
|
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_css('#action_button')
|
||||||
expect(rendered).to have_content('Valider le dossier')
|
expect(rendered).to have_content('Valider le dossier')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state confirmed' do
|
context 'when dossier have state validated' do
|
||||||
before do
|
before do
|
||||||
dossier.confirmed!
|
dossier.validated!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Validé') }
|
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_css('#action_button')
|
||||||
expect(rendered).not_to have_content('Valider le dossier')
|
expect(rendered).not_to have_content('Valider le dossier')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state deposited' do
|
context 'when dossier have state submitted' do
|
||||||
before do
|
before do
|
||||||
dossier.deposited!
|
dossier.submitted!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Déposé') }
|
it { expect(rendered).to have_content('Déposé') }
|
||||||
|
|
||||||
it 'button Valider le dossier n\'est pas present' do
|
it 'button Traiter le dossier is present' do
|
||||||
expect(rendered).not_to have_css('#action_button')
|
expect(rendered).to have_css('#action_button')
|
||||||
|
expect(rendered).to have_content('Traiter le dossier')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'button Valider le dossier is not present' do
|
||||||
expect(rendered).not_to have_content('Valider le dossier')
|
expect(rendered).not_to have_content('Valider le dossier')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state processed' do
|
context 'when dossier have state closed' do
|
||||||
before do
|
before do
|
||||||
dossier.processed!
|
dossier.closed!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Traité') }
|
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_css('#action_button')
|
||||||
expect(rendered).not_to have_content('Valider le dossier')
|
expect(rendered).not_to have_content('Valider le dossier')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO réactiver
|
#TODO réactiver
|
||||||
# context 'la liste des pièces justificatives est présente' do
|
# context 'la liste des pièces justificatives est présente' do
|
||||||
# context 'Attestation MSA' do
|
# context 'Attestation MSA' do
|
||||||
# let(:id_piece_justificative) { 93 }
|
# let(:id_piece_justificative) { 93 }
|
||||||
#
|
#
|
||||||
# it 'la ligne de la pièce justificative est présente' do
|
# it 'la ligne de la pièce justificative est présente' do
|
||||||
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# it 'le bouton "Récupérer" est présent' do
|
# 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_selector("a[href='']")
|
||||||
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Récupérer')
|
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Récupérer')
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# context 'Attestation RDI' do
|
# context 'Attestation RDI' do
|
||||||
# let(:id_piece_justificative) { 103 }
|
# let(:id_piece_justificative) { 103 }
|
||||||
#
|
#
|
||||||
# it 'la ligne de la pièce justificative est présente' do
|
# it 'la ligne de la pièce justificative est présente' do
|
||||||
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# it 'le libelle "Pièce manquante" est présent' do
|
# 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')
|
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Pièce non fournie')
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# context 'Devis' do
|
# context 'Devis' do
|
||||||
# let(:id_piece_justificative) { 388 }
|
# let(:id_piece_justificative) { 388 }
|
||||||
# let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
|
# let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
|
||||||
#
|
#
|
||||||
# before do
|
# before do
|
||||||
# piece_justificative = dossier.pieces_justificatives.where(type_de_piece_justificative_id: 388).first
|
# piece_justificative = dossier.pieces_justificatives.where(type_de_piece_justificative_id: 388).first
|
||||||
# piece_justificative.content = content
|
# piece_justificative.content = content
|
||||||
# piece_justificative.save!
|
# piece_justificative.save!
|
||||||
# visit "/admin/dossiers/#{dossier_id}"
|
# visit "/admin/dossiers/#{dossier_id}"
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# it 'la ligne de la pièce justificative est présente' do
|
# it 'la ligne de la pièce justificative est présente' do
|
||||||
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# it 'le libelle "Consulter" est présent' do
|
# 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}] a")[:href]).to have_content('piece_justificative_388.pdf')
|
||||||
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Consulter')
|
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Consulter')
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe 'backoffice/index.html.haml', type: :view do
|
||||||
assign(:dossiers_en_attente, Dossier.en_attente.decorate)
|
assign(:dossiers_en_attente, Dossier.en_attente.decorate)
|
||||||
assign(:dossiers_termine, Dossier.termine.decorate)
|
assign(:dossiers_termine, Dossier.termine.decorate)
|
||||||
|
|
||||||
decorate_dossier.proposed!
|
decorate_dossier.initiated!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
subject { rendered }
|
subject { rendered }
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'dossiers/_infos_dossier.html.haml', type: :view do
|
describe 'dossiers/_infos_dossier.html.haml', type: :view do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
|
||||||
|
|
||||||
let(:maj_infos) { 'Mettre à jour les informations' }
|
|
||||||
let(:proposer) { 'Soumettre mon dossier' }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:dossier, dossier.decorate)
|
assign(:dossier, dossier.decorate)
|
||||||
assign(:commentaires, dossier.commentaires)
|
assign(:champs, dossier.ordered_champs)
|
||||||
|
assign(:procedure, dossier.procedure)
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'every champs are present on the page' do
|
||||||
|
let(:champs) { dossier.champs }
|
||||||
|
|
||||||
|
it { expect(rendered).to have_content(champs.first.libelle) }
|
||||||
|
it { expect(rendered).to have_content(champs.first.value) }
|
||||||
|
|
||||||
|
it { expect(rendered).to have_content(champs.last.libelle) }
|
||||||
|
it { expect(rendered).to have_content(champs.last.value) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,7 @@ describe 'users/carte/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'si la page précédente est recapitularif' do
|
context 'si la page précédente est recapitularif' do
|
||||||
let(:state) { 'proposed' }
|
let(:state) { 'initiated' }
|
||||||
|
|
||||||
it 'le bouton "Etape suivante" n\'est pas présent' do
|
it 'le bouton "Etape suivante" n\'est pas présent' do
|
||||||
expect(rendered).to_not have_selector('#etape_suivante')
|
expect(rendered).to_not have_selector('#etape_suivante')
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe 'users/description/show.html.haml', type: :view do
|
||||||
before do
|
before do
|
||||||
assign(:dossier, dossier)
|
assign(:dossier, dossier)
|
||||||
assign(:procedure, dossier.procedure)
|
assign(:procedure, dossier.procedure)
|
||||||
|
assign(:champs, dossier.ordered_champs)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'tous les attributs sont présents sur la page' do
|
context 'tous les attributs sont présents sur la page' do
|
||||||
|
@ -26,30 +27,6 @@ describe 'users/description/show.html.haml', type: :view do
|
||||||
expect(rendered).to have_selector('textarea[id=description][name=description]')
|
expect(rendered).to have_selector('textarea[id=description][name=description]')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Montant du projet' do
|
|
||||||
expect(rendered).to have_selector('input[id=montant_projet][name=montant_projet]')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'Montant du projet est de type number' do
|
|
||||||
expect(rendered).to have_selector('input[type=number][id=montant_projet]')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'Montant des aides du projet' do
|
|
||||||
expect(rendered).to have_selector('input[id=montant_aide_demande][name=montant_aide_demande]')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'Montant des aides du projet est de type number' do
|
|
||||||
expect(rendered).to have_selector('input[type=number][id=montant_aide_demande]')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'Date prévisionnelle du projet' do
|
|
||||||
expect(rendered).to have_selector('input[id=date_previsionnelle][name=date_previsionnelle]')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'Date prévisionnelle du projet est de type text avec un data-provide=datepicker' do
|
|
||||||
expect(rendered).to have_selector('input[type=text][id=date_previsionnelle][data-provide=datepicker]')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'Charger votre CERFA (PDF)' do
|
it 'Charger votre CERFA (PDF)' do
|
||||||
expect(rendered).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]')
|
expect(rendered).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]')
|
||||||
end
|
end
|
||||||
|
@ -70,7 +47,7 @@ describe 'users/description/show.html.haml', type: :view do
|
||||||
|
|
||||||
context 'si la page précédente est recapitularif' do
|
context 'si la page précédente est recapitularif' do
|
||||||
before do
|
before do
|
||||||
dossier.proposed!
|
dossier.initiated!
|
||||||
dossier.reload
|
dossier.reload
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
@ -93,9 +70,6 @@ describe 'users/description/show.html.haml', type: :view do
|
||||||
create(:dossier, :with_procedure,
|
create(:dossier, :with_procedure,
|
||||||
nom_projet: 'Projet de test',
|
nom_projet: 'Projet de test',
|
||||||
description: 'Description de test',
|
description: 'Description de test',
|
||||||
montant_projet: 12_000,
|
|
||||||
montant_aide_demande: 3000,
|
|
||||||
date_previsionnelle: '20/01/2016',
|
|
||||||
user: user)
|
user: user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,7 +77,6 @@ describe 'users/description/show.html.haml', type: :view do
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'Nom du projet' do
|
it 'Nom du projet' do
|
||||||
expect(rendered).to have_selector("input[id=nom_projet][value='#{dossier.nom_projet}']")
|
expect(rendered).to have_selector("input[id=nom_projet][value='#{dossier.nom_projet}']")
|
||||||
end
|
end
|
||||||
|
@ -111,17 +84,25 @@ describe 'users/description/show.html.haml', type: :view do
|
||||||
it 'Description du projet' do
|
it 'Description du projet' do
|
||||||
expect(rendered).to have_content("#{dossier.description}")
|
expect(rendered).to have_content("#{dossier.description}")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'Montant du projet' do
|
context 'Champs' do
|
||||||
expect(rendered).to have_selector("input[id=montant_projet][value='#{dossier.montant_projet}']")
|
let(:champs) { dossier.champs }
|
||||||
|
|
||||||
|
before do
|
||||||
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Montant des aides du projet' do
|
describe 'first champs' do
|
||||||
expect(rendered).to have_selector("input[id=montant_aide_demande][value='#{dossier.montant_aide_demande}']")
|
subject { dossier.champs.first }
|
||||||
|
it { expect(rendered).to have_css(".type_champs-#{subject.type_champs}") }
|
||||||
|
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Date prévisionnelle du projet' do
|
describe 'last champs' do
|
||||||
expect(rendered).to have_selector("#date_previsionnelle", dossier.date_previsionnelle)
|
subject { dossier.champs.last }
|
||||||
|
it { expect(rendered).to have_css(".type_champs-#{subject.type_champs}") }
|
||||||
|
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -140,7 +121,7 @@ describe 'users/description/show.html.haml', type: :view do
|
||||||
|
|
||||||
context 'la liste des pièces récupérées automatiquement est signaliée' do
|
context 'la liste des pièces récupérées automatiquement est signaliée' do
|
||||||
it 'Attestation MSA' do
|
it 'Attestation MSA' do
|
||||||
expect(rendered).to have_selector("#piece_justificative_#{all_type_pj_procedure_id[1]}","Nous l'avons récupéré pour vous.")
|
expect(rendered).to have_selector("#piece_justificative_#{all_type_pj_procedure_id[1]}", "Nous l'avons récupéré pour vous.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,18 +55,18 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier state is proposed' do
|
context 'when dossier state is initiated' do
|
||||||
before do
|
before do
|
||||||
dossier.proposed!
|
dossier.initiated!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Soumis') }
|
it { expect(rendered).to have_content('Soumis') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier state is reply' do
|
context 'when dossier state is replied' do
|
||||||
before do
|
before do
|
||||||
dossier.reply!
|
dossier.replied!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -83,9 +83,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
it { expect(rendered).to have_content('Mis à jour') }
|
it { expect(rendered).to have_content('Mis à jour') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier state is confirmed' do
|
context 'when dossier state is validated' do
|
||||||
before do
|
before do
|
||||||
dossier.confirmed!
|
dossier.validated!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier state is deposited' do
|
context 'when dossier state is submitted' do
|
||||||
before do
|
before do
|
||||||
dossier.deposited!
|
dossier.submitted!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
|
|
||||||
context 'when dossier state is traité' do
|
context 'when dossier state is traité' do
|
||||||
before do
|
before do
|
||||||
dossier.processed!
|
dossier.closed!
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
it { expect(rendered).to have_content('Traité') }
|
it { expect(rendered).to have_content('Traité') }
|
||||||
|
|
Loading…
Reference in a new issue