commit
8c7a446f3f
27 changed files with 137 additions and 452 deletions
8
Gemfile
8
Gemfile
|
@ -124,19 +124,23 @@ gem "administrate"
|
||||||
gem 'rack-mini-profiler'
|
gem 'rack-mini-profiler'
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'capybara'
|
|
||||||
gem 'launchy'
|
gem 'launchy'
|
||||||
gem 'factory_bot'
|
gem 'factory_bot'
|
||||||
gem 'database_cleaner'
|
gem 'database_cleaner'
|
||||||
gem 'webmock'
|
gem 'webmock'
|
||||||
gem 'shoulda-matchers', require: false
|
gem 'shoulda-matchers', require: false
|
||||||
gem 'capybara-selenium'
|
|
||||||
gem 'timecop'
|
gem 'timecop'
|
||||||
gem 'guard'
|
gem 'guard'
|
||||||
gem 'guard-rspec', require: false
|
gem 'guard-rspec', require: false
|
||||||
gem 'guard-livereload', require: false
|
gem 'guard-livereload', require: false
|
||||||
gem 'vcr'
|
gem 'vcr'
|
||||||
gem 'rails-controller-testing'
|
gem 'rails-controller-testing'
|
||||||
|
|
||||||
|
# Integration testing
|
||||||
|
gem 'capybara'
|
||||||
|
gem 'capybara-selenium'
|
||||||
|
# Save a dump of the page when an integration test fails
|
||||||
|
gem 'capybara-screenshot'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
|
|
@ -118,6 +118,9 @@ GEM
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
xpath (>= 2.0, < 4.0)
|
xpath (>= 2.0, < 4.0)
|
||||||
|
capybara-screenshot (1.0.21)
|
||||||
|
capybara (>= 1.0, < 4)
|
||||||
|
launchy
|
||||||
capybara-selenium (0.0.6)
|
capybara-selenium (0.0.6)
|
||||||
capybara
|
capybara
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
|
@ -798,6 +801,7 @@ DEPENDENCIES
|
||||||
browser
|
browser
|
||||||
byebug
|
byebug
|
||||||
capybara
|
capybara
|
||||||
|
capybara-screenshot
|
||||||
capybara-selenium
|
capybara-selenium
|
||||||
carrierwave
|
carrierwave
|
||||||
carrierwave-i18n
|
carrierwave-i18n
|
||||||
|
|
|
@ -38,6 +38,10 @@ $auth-breakpoint: $two-columns-breakpoint;
|
||||||
.procedure-description {
|
.procedure-description {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-bottom: 2 * $default-spacer;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: $auth-breakpoint) {
|
@media (max-width: $auth-breakpoint) {
|
||||||
display: none; // TO FIX : make this description available for small devices
|
display: none; // TO FIX : make this description available for small devices
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
@import "constants";
|
@import "constants";
|
||||||
|
|
||||||
#users-index,
|
|
||||||
#admins-index {
|
#admins-index {
|
||||||
margin-left: 2rem;
|
margin-left: 2rem;
|
||||||
margin-right: 2rem;
|
margin-right: 2rem;
|
||||||
|
|
|
@ -174,18 +174,21 @@ class Admin::ProceduresController < AdminController
|
||||||
redirect_to admin_procedures_path
|
redirect_to admin_procedures_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
SIGNIFICANT_DOSSIERS_THRESHOLD = 30
|
||||||
|
|
||||||
def new_from_existing
|
def new_from_existing
|
||||||
procedures_with_more_than_30_dossiers_ids = Procedure
|
significant_procedure_ids = Procedure
|
||||||
.publiees_ou_archivees
|
.publiees_ou_archivees
|
||||||
.joins(:dossiers)
|
.joins(:dossiers)
|
||||||
.group("procedures.id")
|
.group("procedures.id")
|
||||||
.having("count(dossiers.id) > ?", 30)
|
.having("count(dossiers.id) >= ?", SIGNIFICANT_DOSSIERS_THRESHOLD)
|
||||||
.pluck('procedures.id')
|
.pluck('procedures.id')
|
||||||
|
|
||||||
@grouped_procedures = Procedure
|
@grouped_procedures = Procedure
|
||||||
.where(id: procedures_with_more_than_30_dossiers_ids)
|
.includes(:administrateur, :service)
|
||||||
.group_by(&:administrateur)
|
.where(id: significant_procedure_ids)
|
||||||
.sort_by { |a, _| a.created_at }
|
.group_by(&:organisation_name)
|
||||||
|
.sort_by { |_, procedures| procedures.first.created_at }
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_class
|
def active_class
|
||||||
|
|
|
@ -7,6 +7,20 @@ module NewUser
|
||||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
|
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
|
||||||
before_action :forbid_invite_submission!, only: [:update]
|
before_action :forbid_invite_submission!, only: [:update]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
||||||
|
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
|
||||||
|
|
||||||
|
@current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count)
|
||||||
|
|
||||||
|
@dossiers = case @current_tab
|
||||||
|
when 'mes-dossiers'
|
||||||
|
@user_dossiers
|
||||||
|
when 'dossiers-invites'
|
||||||
|
@dossiers_invites
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def attestation
|
def attestation
|
||||||
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
||||||
end
|
end
|
||||||
|
@ -87,20 +101,6 @@ module NewUser
|
||||||
@dossier = current_user.dossiers.includes(:procedure).find(params[:id])
|
@dossier = current_user.dossiers.includes(:procedure).find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
|
||||||
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
|
||||||
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
|
|
||||||
|
|
||||||
@current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count)
|
|
||||||
|
|
||||||
@dossiers = case @current_tab
|
|
||||||
when 'mes-dossiers'
|
|
||||||
@user_dossiers
|
|
||||||
when 'dossiers-invites'
|
|
||||||
@dossiers_invites
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def ask_deletion
|
def ask_deletion
|
||||||
dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id])
|
dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id])
|
||||||
|
|
||||||
|
|
|
@ -12,32 +12,6 @@ class Users::DossiersController < UsersController
|
||||||
authorized_routes? self.class
|
authorized_routes? self.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
|
||||||
@liste ||= params[:liste] || 'a_traiter'
|
|
||||||
|
|
||||||
@user_dossiers = current_user.dossiers
|
|
||||||
|
|
||||||
@dossiers_filtered = case @liste
|
|
||||||
when 'brouillon'
|
|
||||||
@user_dossiers.state_brouillon.order_by_updated_at
|
|
||||||
when 'a_traiter'
|
|
||||||
@user_dossiers.state_en_construction.order_by_updated_at
|
|
||||||
when 'en_instruction'
|
|
||||||
@user_dossiers.state_en_instruction.order_by_updated_at
|
|
||||||
when 'termine'
|
|
||||||
@user_dossiers.state_termine.order_by_updated_at
|
|
||||||
when 'invite'
|
|
||||||
current_user.invites
|
|
||||||
else
|
|
||||||
return redirect_to users_dossiers_path
|
|
||||||
end
|
|
||||||
|
|
||||||
@dossiers = smart_listing_create :dossiers,
|
|
||||||
@dossiers_filtered,
|
|
||||||
partial: "users/dossiers/list",
|
|
||||||
array: true
|
|
||||||
end
|
|
||||||
|
|
||||||
def commencer_test
|
def commencer_test
|
||||||
procedure_path = ProcedurePath.find_by(path: params[:procedure_path])
|
procedure_path = ProcedurePath.find_by(path: params[:procedure_path])
|
||||||
procedure = procedure_path&.test_procedure
|
procedure = procedure_path&.test_procedure
|
||||||
|
|
|
@ -16,9 +16,7 @@ module DossierHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def url_for_dossier(dossier)
|
def url_for_dossier(dossier)
|
||||||
if dossier.kind_of? Invite
|
if dossier.brouillon?
|
||||||
users_dossiers_invite_path(id: dossier.id)
|
|
||||||
elsif dossier.brouillon?
|
|
||||||
modifier_dossier_path(dossier)
|
modifier_dossier_path(dossier)
|
||||||
else
|
else
|
||||||
users_dossier_recapitulatif_path(dossier)
|
users_dossier_recapitulatif_path(dossier)
|
||||||
|
|
|
@ -152,6 +152,10 @@ class Procedure < ApplicationRecord
|
||||||
libelle.parameterize.first(50)
|
libelle.parameterize.first(50)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def organisation_name
|
||||||
|
service&.nom || organisation
|
||||||
|
end
|
||||||
|
|
||||||
def types_de_champ_ordered
|
def types_de_champ_ordered
|
||||||
types_de_champ.order(:order_place)
|
types_de_champ.order(:order_place)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
%h1 Gestion des accompagnateurs
|
%h1 Accompagnateurs disponibles
|
||||||
%br
|
|
||||||
|
%p
|
||||||
|
Cette page vous permet de gérer la liste des accompagnateurs disponibles pour être affectés à une procédure.
|
||||||
|
|
||||||
|
%p{ style: 'font-style: italic' }
|
||||||
|
N.B. : cette page ne concerne que la liste des personnes disponibles. Si vous souhaitez affecter ou enlever un accompagnateur d'une procédure particulière,
|
||||||
|
utilisez plutôt la
|
||||||
|
= link_to "page de la procédure", admin_procedures_path
|
||||||
|
concernée.
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-xs-4
|
.col-xs-4
|
||||||
|
|
||||||
= smart_listing_render :gestionnaires
|
= smart_listing_render :gestionnaires
|
||||||
.col-xs-1
|
.col-xs-1
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
%br
|
%br
|
||||||
- @grouped_procedures.each do |_, procedures|
|
- @grouped_procedures.each do |_, procedures|
|
||||||
%b
|
%b
|
||||||
= procedures.first.organisation
|
= procedures.first.organisation_name
|
||||||
%table{ style: 'margin-bottom: 40px;' }
|
%table{ style: 'margin-bottom: 40px;' }
|
||||||
- procedures.sort_by(&:id).each do |procedure|
|
- procedures.sort_by(&:id).each do |procedure|
|
||||||
%tr{ style: 'height: 36px;' }
|
%tr{ style: 'height: 36px;' }
|
||||||
|
|
|
@ -26,7 +26,7 @@ as well as a link to its edit page.
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<% if dossier.termine? %>
|
<% if dossier.termine? %>
|
||||||
<%= link_to 'repasser en instruction', change_state_to_instruction_manager_dossier_path(dossier), method: :post, class: 'button' %>
|
<%= link_to 'Repasser en instruction', change_state_to_instruction_manager_dossier_path(dossier), method: :post, class: 'button', data: { confirm: "Repasser en instruction ?" } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div>
|
<div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -56,5 +56,5 @@
|
||||||
- else
|
- else
|
||||||
.dossiers-table-empty
|
.dossiers-table-empty
|
||||||
%h2.empty-text Aucun dossier.
|
%h2.empty-text Aucun dossier.
|
||||||
%p.empty-text-details Pour l’instant vous n’avez commencé aucune démarche.
|
%p.empty-text-details Vous n’avez pas encore commencé de démarche.
|
||||||
= link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary"
|
= link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary"
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
- if smart_listing.present?
|
|
||||||
%table#dossiers-list.table
|
|
||||||
%thead
|
|
||||||
%th#sort-id.col-md-1.col-lg-1.col-sm-1.col-xs-1= smart_listing.sortable 'Numéro', 'id'
|
|
||||||
%th#sort-libelle.col-xs-5= smart_listing.sortable 'Procédure', 'procedure.libelle'
|
|
||||||
%th#sort-state.col-xs-2= smart_listing.sortable 'État', 'state'
|
|
||||||
%th#sort-updated.col-xs-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
|
|
||||||
- if @liste == "brouillon"
|
|
||||||
%th.col-xs-2= 'Action'
|
|
||||||
- @dossiers.each do |dossier|
|
|
||||||
- if dossier.kind_of? Invite
|
|
||||||
- invite = dossier
|
|
||||||
- dossier = invite.dossier.decorate
|
|
||||||
- else
|
|
||||||
- dossier = dossier.decorate
|
|
||||||
|
|
||||||
- dossier_url = users_dossiers_invite_path(id: invite.id) if invite.present?
|
|
||||||
- if invite.nil?
|
|
||||||
- dossier_url = users_dossier_recapitulatif_path(dossier) if !dossier.brouillon?
|
|
||||||
- dossier_url = modifier_dossier_path(dossier) if dossier.brouillon?
|
|
||||||
|
|
||||||
%tr{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => dossier_url }
|
|
||||||
%td.center
|
|
||||||
= dossier.id
|
|
||||||
%td
|
|
||||||
= dossier.procedure.libelle
|
|
||||||
|
|
||||||
%td{ id: "dossier_#{dossier.id}_state" }= dossier.display_state
|
|
||||||
%td= dossier.last_update
|
|
||||||
%td= link_to('X', url_for(controller: 'dossiers', action: :destroy, id: dossier.id), 'data-confirm' => "Voulez-vous supprimer le brouillon ?", 'data-method' => :delete, class: 'btn-sm btn-danger') if @liste == "brouillon"
|
|
||||||
|
|
||||||
= smart_listing.paginate
|
|
||||||
= smart_listing.pagination_per_page_links
|
|
||||||
%br
|
|
||||||
|
|
||||||
- else
|
|
||||||
%h4.center
|
|
||||||
Aucun dossier
|
|
|
@ -1,52 +0,0 @@
|
||||||
#state_description.row{ style: 'width: 55%; margin-left: auto; margin-right: auto;' }
|
|
||||||
.panel.panel-info
|
|
||||||
.panel-body.center
|
|
||||||
.row
|
|
||||||
.col-md-1.col-lg-1.col-sm-1.col-xs-1
|
|
||||||
.fa.fa-info-circle.text-info{ style: 'font-size: 2em; margin-top: 20%;' }
|
|
||||||
.col-xs-11
|
|
||||||
- case liste
|
|
||||||
- when 'brouillon'
|
|
||||||
Les dossiers présents dans cette liste
|
|
||||||
%b
|
|
||||||
n'ont pas encore été soumis aux services instructeurs.
|
|
||||||
Ils ne sont visibles que par vous.
|
|
||||||
- when 'nouveaux'
|
|
||||||
Les dossiers présents dans cette liste
|
|
||||||
%b
|
|
||||||
n'ont pas encore été ouverts
|
|
||||||
par les services instructeurs. Une notification vous sera envoyée quand votre demande aura été étudiée.
|
|
||||||
- when 'a_traiter'
|
|
||||||
Les dossiers présents dans cette liste sont
|
|
||||||
%b
|
|
||||||
visibles par les services instructeurs.
|
|
||||||
%br
|
|
||||||
Ces dossiers ne sont pas encore figés et peuvent être modifiés à souhait.
|
|
||||||
- when 'en_attente'
|
|
||||||
Les dossiers présents dans cette liste sont
|
|
||||||
%b
|
|
||||||
en cours de relecture par le service instructeur.
|
|
||||||
Il reviendra vers vous si des informations ou documents sont manquants pour le futur examen de votre dossier.
|
|
||||||
- when 'valides'
|
|
||||||
Les dossiers présents dans cette liste ont été
|
|
||||||
%b
|
|
||||||
relus et considérés comme complets
|
|
||||||
pour examen par les services instructeurs. Ceux-ci ne peuvent maintenant plus être modifiés. Il faut que vous procédiez à leur dépôt afin qu'une décision finale soit rendue.
|
|
||||||
- when 'en_instruction'
|
|
||||||
Les dossiers présents dans cette liste sont
|
|
||||||
%b
|
|
||||||
en cours de réception
|
|
||||||
ou
|
|
||||||
%b
|
|
||||||
en cours d'examen
|
|
||||||
par les services instructeurs. Une notification vous sera envoyée une fois qu'une décision aura été rendue.
|
|
||||||
- when 'termine'
|
|
||||||
Les dossiers présents dans cette liste sont ceux qui ont été instruits et pour lesquels
|
|
||||||
%b
|
|
||||||
une décision finale a été rendue.
|
|
||||||
Ils peuvent posséder trois états différents : Accepté, Refusé ou Sans Suite.
|
|
||||||
- when 'invite'
|
|
||||||
Les dossiers présents dans cette liste sont ceux
|
|
||||||
%b
|
|
||||||
auxquels vous avez été invités
|
|
||||||
à participer afin d'émettre un avis ou de fournir des documents complémentaires.
|
|
|
@ -1,15 +0,0 @@
|
||||||
#users-index
|
|
||||||
.default-data-block.default_visible
|
|
||||||
.row.show-block#new_dossiers
|
|
||||||
.header
|
|
||||||
.col-lg-10.col-md-10.col-sm-10.col-xs-10.title
|
|
||||||
.carret-right
|
|
||||||
.carret-down
|
|
||||||
Dossiers
|
|
||||||
.col-lg-2.col-md-2.col-sm-2.col-xs-2.count
|
|
||||||
-# 0
|
|
||||||
-# dossiers
|
|
||||||
.body
|
|
||||||
= smart_listing_render :dossiers
|
|
||||||
|
|
||||||
= render partial: 'state_description', locals: { liste: @liste }
|
|
|
@ -1,2 +0,0 @@
|
||||||
<%= smart_listing_update :dossiers %>
|
|
||||||
link_init();
|
|
|
@ -125,7 +125,11 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
get 'text_summary' => 'dossiers#text_summary'
|
get 'text_summary' => 'dossiers#text_summary'
|
||||||
end
|
end
|
||||||
resource :dossiers
|
|
||||||
|
resource 'dossiers'
|
||||||
|
|
||||||
|
# Redirection of legacy "/users/dossiers" route to "/dossiers"
|
||||||
|
get 'dossiers', to: redirect('/dossiers')
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :gestionnaire do
|
namespace :gestionnaire do
|
||||||
|
|
|
@ -525,6 +525,50 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET #new_from_existing' do
|
||||||
|
before do
|
||||||
|
stub_const("Admin::ProceduresController::SIGNIFICANT_DOSSIERS_THRESHOLD", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { get :new_from_existing }
|
||||||
|
let(:grouped_procedures) { subject; assigns(:grouped_procedures) }
|
||||||
|
let(:response_procedures) { grouped_procedures.map{ |o, procedures| procedures }.flatten }
|
||||||
|
|
||||||
|
describe 'selecting' do
|
||||||
|
let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) }
|
||||||
|
let!(:large_published_procedure) { create(:procedure_with_dossiers, :published, dossiers_count: 2) }
|
||||||
|
let!(:large_archived_procedure) { create(:procedure_with_dossiers, :archived, dossiers_count: 2) }
|
||||||
|
let!(:small_archived_procedure) { create(:procedure_with_dossiers, :archived, dossiers_count: 1) }
|
||||||
|
|
||||||
|
it 'displays published and archived procedures' do
|
||||||
|
expect(response_procedures).to include(large_published_procedure)
|
||||||
|
expect(response_procedures).to include(large_archived_procedure)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'doesn’t display procedures without a significant number of dossiers' do
|
||||||
|
expect(response_procedures).not_to include(small_archived_procedure)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'doesn’t display draft procedures' do
|
||||||
|
expect(response_procedures).not_to include(large_draft_procedure)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'grouping' do
|
||||||
|
let(:service_1) { create(:service, nom: 'DDT des Vosges') }
|
||||||
|
let(:service_2) { create(:service, nom: 'DDT du Loiret') }
|
||||||
|
let!(:procedure_with_service_1) { create(:procedure_with_dossiers, :published, organisation: nil, service: service_1, dossiers_count: 2) }
|
||||||
|
let!(:procedure_with_service_2) { create(:procedure_with_dossiers, :published, organisation: nil, service: service_2, dossiers_count: 2) }
|
||||||
|
let!(:procedure_without_service) { create(:procedure_with_dossiers, :published, organisation: 'DDT du Loiret', dossiers_count: 2) }
|
||||||
|
|
||||||
|
it 'groups procedures with services as well as procedures with organisations' do
|
||||||
|
expect(grouped_procedures.length).to eq 2
|
||||||
|
expect(grouped_procedures.find{ |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1)
|
||||||
|
expect(grouped_procedures.find{ |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET #path_list' do
|
describe 'GET #path_list' do
|
||||||
let!(:procedure) { create(:procedure, :published, administrateur: admin) }
|
let!(:procedure) { create(:procedure, :published, administrateur: admin) }
|
||||||
let(:admin2) { create(:administrateur) }
|
let(:admin2) { create(:administrateur) }
|
||||||
|
|
|
@ -427,84 +427,6 @@ describe Users::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #a_traiter' do
|
|
||||||
context 'when user is connected' do
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http success' do
|
|
||||||
get :index, params: { liste: :a_traiter }
|
|
||||||
expect(response).to have_http_status(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #en_instruction' do
|
|
||||||
context 'when user is connected' do
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http success' do
|
|
||||||
get :index, params: { liste: :en_instruction }
|
|
||||||
expect(response).to have_http_status(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #brouillon' do
|
|
||||||
context 'when user is connected' do
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http success' do
|
|
||||||
get :index, params: { liste: :brouillon }
|
|
||||||
expect(response).to have_http_status(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #termine' do
|
|
||||||
context 'when user is connected' do
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http success' do
|
|
||||||
get :index, params: { liste: :termine }
|
|
||||||
expect(response).to have_http_status(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #invite' do
|
|
||||||
context 'when user is connected' do
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http success' do
|
|
||||||
get :index, params: { liste: :invite }
|
|
||||||
expect(response).to have_http_status(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #list_fake' do
|
|
||||||
context 'when user is connected' do
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http success' do
|
|
||||||
get :index, params: { liste: :list_fake }
|
|
||||||
expect(response).to redirect_to(users_dossiers_path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'Get #text_summary' do
|
describe 'Get #text_summary' do
|
||||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,16 @@ FactoryBot.define do
|
||||||
duree_conservation_dossiers_dans_ds 3
|
duree_conservation_dossiers_dans_ds 3
|
||||||
duree_conservation_dossiers_hors_ds 6
|
duree_conservation_dossiers_hors_ds 6
|
||||||
|
|
||||||
|
factory :procedure_with_dossiers do
|
||||||
|
transient do
|
||||||
|
dossiers_count 1
|
||||||
|
end
|
||||||
|
|
||||||
|
after(:build) do |procedure, _evaluator|
|
||||||
|
procedure.dossiers << create_list(:dossier, _evaluator.dossiers_count, procedure: procedure)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
if procedure.module_api_carto.nil?
|
if procedure.module_api_carto.nil?
|
||||||
module_api_carto = create(:module_api_carto)
|
module_api_carto = create(:module_api_carto)
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'As a User I want to sort and paginate dossiers', js: true do
|
|
||||||
let(:user) { create(:user) }
|
|
||||||
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, ask_birthday: true) }
|
|
||||||
|
|
||||||
before "Create dossier" do
|
|
||||||
login_as user, scope: :user
|
|
||||||
|
|
||||||
50.times do
|
|
||||||
Dossier.create(procedure_id: procedure_for_individual.id, user_id: user.id, state: "en_construction")
|
|
||||||
end
|
|
||||||
|
|
||||||
visit root_path
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'After sign_in, I can see my 51 dossiers on the index' do
|
|
||||||
scenario 'Using sort' do
|
|
||||||
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
|
|
||||||
expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
|
|
||||||
expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq(user.dossiers.second.id.to_s)
|
|
||||||
visit "/users/dossiers?dossiers_smart_listing[sort][id]=desc"
|
|
||||||
expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 49).to_s)
|
|
||||||
expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq((user.dossiers.first.id + 48).to_s)
|
|
||||||
visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
|
|
||||||
expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
|
|
||||||
expect(page.all(:css, '#dossiers-list tr')[2].text.split(" ").first).to eq(user.dossiers.second.id.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
# This test always fail with ajax timeout error...
|
|
||||||
# scenario 'Using pagination' do
|
|
||||||
# visit "/users/dossiers?dossiers_smart_listing[sort][id]=asc"
|
|
||||||
# expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq(user.dossiers.first.id.to_s)
|
|
||||||
# page.find('.next_page a').click
|
|
||||||
# wait_for_ajax
|
|
||||||
# expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 10).to_s)
|
|
||||||
# page.find('.next_page a').click
|
|
||||||
# wait_for_ajax
|
|
||||||
# expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id + 20).to_s)
|
|
||||||
# page.find('.prev a').click
|
|
||||||
# wait_for_ajax
|
|
||||||
# page.find('.prev a').click
|
|
||||||
# wait_for_ajax
|
|
||||||
# expect(page.all(:css, '#dossiers-list tr')[1].text.split(" ").first).to eq((user.dossiers.first.id).to_s)
|
|
||||||
# end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,65 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'on click on tabs button' do
|
|
||||||
let(:user) { create :user }
|
|
||||||
|
|
||||||
let(:dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction') }
|
|
||||||
|
|
||||||
before do
|
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'en_construction')
|
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'en_instruction')
|
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'accepte')
|
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'refuse')
|
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'sans_suite')
|
|
||||||
|
|
||||||
create :invite, dossier: dossier_invite, user: user
|
|
||||||
|
|
||||||
login_as user, scope: :user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when user is logged in' do
|
|
||||||
context 'when he click on tabs en construction' do
|
|
||||||
before do
|
|
||||||
visit users_dossiers_url(liste: :a_traiter)
|
|
||||||
page.click_on 'En construction 1'
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'it redirect to users dossier termine' do
|
|
||||||
expect(page).to have_css('#users-index')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when he click on tabs en examen' do
|
|
||||||
before do
|
|
||||||
visit users_dossiers_url(liste: :en_instruction)
|
|
||||||
page.click_on 'En instruction 1'
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'it redirect to users dossier termine' do
|
|
||||||
expect(page).to have_css('#users-index')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when he click on tabs termine' do
|
|
||||||
before do
|
|
||||||
visit users_dossiers_url(liste: :termine)
|
|
||||||
page.click_on 'Terminé 3'
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'it redirect to users dossier termine' do
|
|
||||||
expect(page).to have_css('#users-index')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when he click on tabs invitation' do
|
|
||||||
before do
|
|
||||||
visit users_dossiers_url(liste: :invite)
|
|
||||||
page.click_on 'Invitation 1'
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'it redirect to users dossier invites' do
|
|
||||||
expect(page).to have_css('#users-index')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -29,11 +29,6 @@ RSpec.describe DossierHelper, type: :helper do
|
||||||
describe ".url_for_dossier" do
|
describe ".url_for_dossier" do
|
||||||
subject { url_for_dossier(dossier) }
|
subject { url_for_dossier(dossier) }
|
||||||
|
|
||||||
context "when the dossier is an invitation" do
|
|
||||||
let(:dossier) { create(:invite) }
|
|
||||||
it { is_expected.to eq "/users/dossiers/invites/#{dossier.id}" }
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the dossier is in the brouillon state" do
|
context "when the dossier is in the brouillon state" do
|
||||||
let(:dossier) { create(:dossier, state: 'brouillon') }
|
let(:dossier) { create(:dossier, state: 'brouillon') }
|
||||||
it { is_expected.to eq "/dossiers/#{dossier.id}/modifier" }
|
it { is_expected.to eq "/dossiers/#{dossier.id}/modifier" }
|
||||||
|
|
|
@ -735,6 +735,19 @@ describe Procedure do
|
||||||
it { expect(Champ.count).to eq(0) }
|
it { expect(Champ.count).to eq(0) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#organisation_name" do
|
||||||
|
subject { procedure.organisation_name }
|
||||||
|
context 'when the procedure has a service (and no organization)' do
|
||||||
|
let(:procedure) { create(:procedure, :with_service, organisation: nil) }
|
||||||
|
it { is_expected.to eq procedure.service.nom }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the procedure has an organization (and no service)' do
|
||||||
|
let(:procedure) { create(:procedure, organisation: 'DDT des Vosges', service: nil) }
|
||||||
|
it { is_expected.to eq procedure.organisation }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#juridique_required' do
|
describe '#juridique_required' do
|
||||||
it 'automatically jumps to true once cadre_juridique or deliberation have been set' do
|
it 'automatically jumps to true once cadre_juridique or deliberation have been set' do
|
||||||
p = create(
|
p = create(
|
||||||
|
|
|
@ -22,6 +22,7 @@ ENV['RAILS_ENV'] ||= 'test'
|
||||||
require File.expand_path('../config/environment', __dir__)
|
require File.expand_path('../config/environment', __dir__)
|
||||||
require 'rspec/rails'
|
require 'rspec/rails'
|
||||||
require 'capybara/rspec'
|
require 'capybara/rspec'
|
||||||
|
require 'capybara-screenshot/rspec'
|
||||||
require 'database_cleaner'
|
require 'database_cleaner'
|
||||||
require 'webmock/rspec'
|
require 'webmock/rspec'
|
||||||
require 'shoulda-matchers'
|
require 'shoulda-matchers'
|
||||||
|
@ -50,6 +51,15 @@ ActiveSupport::Deprecation.silenced = true
|
||||||
|
|
||||||
Capybara.default_max_wait_time = 1
|
Capybara.default_max_wait_time = 1
|
||||||
|
|
||||||
|
# Save a snapshot of the HTML page when an integration test fails
|
||||||
|
Capybara::Screenshot.autosave_on_failure = true
|
||||||
|
# Keep only the screenshots generated from the last failing test suite
|
||||||
|
Capybara::Screenshot.prune_strategy = :keep_last_run
|
||||||
|
# Tell Capybara::Screenshot how to take screenshots when using the headless_chrome driver
|
||||||
|
Capybara::Screenshot.register_driver :headless_chrome do |driver, path|
|
||||||
|
driver.browser.save_screenshot(path)
|
||||||
|
end
|
||||||
|
|
||||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||||
# in spec/support/ and its subdirectories.
|
# in spec/support/ and its subdirectories.
|
||||||
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe 'users/dossiers/index.html.haml', type: :view do
|
|
||||||
let(:user) { create(:user) }
|
|
||||||
|
|
||||||
let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, user: user, state: 'en_construction').decorate }
|
|
||||||
let!(:decorate_dossier_en_instruction) { create(:dossier, :with_entreprise, user: user, state: 'en_instruction').decorate }
|
|
||||||
let!(:decorate_dossier_accepte) { create(:dossier, :with_entreprise, user: user, state: 'accepte').decorate }
|
|
||||||
let!(:decorate_dossier_refuse) { create(:dossier, :with_entreprise, user: user, state: 'refuse').decorate }
|
|
||||||
let!(:decorate_dossier_sans_suite) { create(:dossier, :with_entreprise, user: user, state: 'sans_suite').decorate }
|
|
||||||
let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction').decorate }
|
|
||||||
|
|
||||||
before do
|
|
||||||
create :invite, dossier: decorate_dossier_invite, user: user
|
|
||||||
end
|
|
||||||
|
|
||||||
shared_examples 'check_tab_content' do
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
|
|
||||||
assign(:dossiers, (smart_listing_create :dossiers,
|
|
||||||
dossiers_to_display,
|
|
||||||
partial: "users/dossiers/list",
|
|
||||||
array: true))
|
|
||||||
render
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { rendered }
|
|
||||||
|
|
||||||
it 'displays the total count' do
|
|
||||||
expect(dossiers_to_display.count).to eq total_dossiers
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'displays data in columns' do
|
|
||||||
expect(rendered).to have_content(decorate_dossier_at_check.id)
|
|
||||||
expect(rendered).to have_content(decorate_dossier_at_check.procedure.libelle)
|
|
||||||
expect(rendered).to have_content(decorate_dossier_at_check.display_state)
|
|
||||||
expect(rendered).to have_content(decorate_dossier_at_check.last_update)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'on tab en construction' do
|
|
||||||
let(:total_dossiers) { 1 }
|
|
||||||
let(:active_class) { '.active .text-danger' }
|
|
||||||
let(:dossiers_to_display) { user.dossiers.state_en_construction }
|
|
||||||
let(:liste) { 'a_traiter' }
|
|
||||||
|
|
||||||
it_behaves_like 'check_tab_content' do
|
|
||||||
let(:decorate_dossier_at_check) { decorate_dossier_en_construction }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'on tab etude en examen' do
|
|
||||||
let(:total_dossiers) { 1 }
|
|
||||||
let(:active_class) { '.active .text-default' }
|
|
||||||
let(:dossiers_to_display) { user.dossiers.state_en_instruction }
|
|
||||||
let(:liste) { 'en_instruction' }
|
|
||||||
|
|
||||||
it_behaves_like 'check_tab_content' do
|
|
||||||
let(:decorate_dossier_at_check) { decorate_dossier_en_instruction }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'on tab etude termine' do
|
|
||||||
let(:total_dossiers) { 3 }
|
|
||||||
let(:active_class) { '.active .text-success' }
|
|
||||||
let(:dossiers_to_display) { user.dossiers.state_termine }
|
|
||||||
let(:liste) { 'termine' }
|
|
||||||
|
|
||||||
it_behaves_like 'check_tab_content' do
|
|
||||||
let(:decorate_dossier_at_check) { decorate_dossier_accepte }
|
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like 'check_tab_content' do
|
|
||||||
let(:decorate_dossier_at_check) { decorate_dossier_refuse }
|
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like 'check_tab_content' do
|
|
||||||
let(:decorate_dossier_at_check) { decorate_dossier_sans_suite }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'on tab etude invite' do
|
|
||||||
let(:total_dossiers) { 1 }
|
|
||||||
let(:active_class) { '.active .text-warning' }
|
|
||||||
let(:dossiers_to_display) { user.invites }
|
|
||||||
let(:liste) { 'invite' }
|
|
||||||
|
|
||||||
it_behaves_like 'check_tab_content' do
|
|
||||||
let(:decorate_dossier_at_check) { decorate_dossier_invite }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue