- Add new status for a dossier : received, refused and without_continuation

- Add new and rename tabs on gestionnaire all dossiers view
/!\ WARNING : One test does not pasted. He will be corrected in the next commit
This commit is contained in:
Xavier J 2016-08-11 15:27:35 +02:00
parent 85e7af840a
commit 1a92382259
19 changed files with 506 additions and 195 deletions

View file

@ -32,8 +32,18 @@
//= require handlebars
//= require typeahead.bundle
$(document).on('page:load', scroll_to);
$(document).ready(scroll_to);
$(document).on('page:load', application_init);
$(document).ready(application_init);
function application_init(){
tooltip_init();
scroll_to();
}
function tooltip_init() {
$('[data-toggle="tooltip"]').tooltip({delay: { "show": 800, "hide": 100 }});
}
function scroll_to() {
$('.js-scrollTo').on('click', function () { // Au clic sur un élément

View file

@ -36,7 +36,7 @@ body {
}
.wysihtml5-sandbox {
resize:vertical;
resize: vertical;
}
#wrap {
@ -101,7 +101,6 @@ body {
margin-right: 105px;
}
#header {
top: 0;
left: -3px;
@ -111,7 +110,6 @@ body {
}
.navbar {
height: 35px;
background-color: rgba(235, 235, 235, 0.95);
@ -123,6 +121,18 @@ body {
}
.text-purple {
color: #8B008B
}
.text-default {
color: grey;
}
.progress-bar-purple {
background-color: #800080;
}
.btn {
box-shadow: none !important;
}
@ -178,12 +188,12 @@ div.pagination {
text-align: center;
}
.alert{
.alert {
margin-bottom: 0px;
}
.alert.alert-success.move_up,
.alert.alert-danger.siret{
.alert.alert-danger.siret {
position: fixed;
top: 0px;
left: 0;

View file

@ -5,11 +5,7 @@ class Backoffice::DossiersController < ApplicationController
before_action :authenticate_gestionnaire!
def index
@liste = params[:liste] || 'a_traiter'
smartlisting_dossier
total_dossiers_per_state
smartlisting_dossier (params[:liste] || 'a_traiter')
end
def show
@ -21,13 +17,14 @@ class Backoffice::DossiersController < ApplicationController
@search_terms = params[:q]
@dossiers_search, @dossier = Dossier.search(current_gestionnaire, @search_terms)
create_dossiers_list_facade
unless @dossiers_search.empty?
@dossiers_search = @dossiers_search.paginate(:page => params[:page]).decorate
end
@dossier = @dossier.decorate unless @dossier.nil?
total_dossiers_per_state
rescue RuntimeError
@dossiers_search = []
end
@ -65,52 +62,25 @@ class Backoffice::DossiersController < ApplicationController
rescue NoMethodError
@liste = 'a_traiter'
end
smartlisting_dossier
smartlisting_dossier @liste
render 'backoffice/dossiers/index', formats: :js
end
private
def smartlisting_dossier
def smartlisting_dossier liste
create_dossiers_list_facade liste
@dossiers = smart_listing_create :dossiers,
dossiers_to_display,
@dossiers_list_facade.dossiers_to_display,
partial: "backoffice/dossiers/list",
array: true
end
def dossiers_to_display
{'a_traiter' => waiting_for_gestionnaire,
'en_attente' => waiting_for_user,
'termine' => termine,
'suivi' => suivi}[@liste]
end
def waiting_for_gestionnaire
@a_traiter_class = (@liste == 'a_traiter' ? 'active' : '')
@waiting_for_gestionnaire ||= current_gestionnaire.dossiers_filter.waiting_for_gestionnaire
end
def waiting_for_user
@en_attente_class = (@liste == 'en_attente' ? 'active' : '')
@waiting_for_user ||= current_gestionnaire.dossiers_filter.waiting_for_user
end
def termine
@termine_class = (@liste == 'termine' ? 'active' : '')
@termine ||= current_gestionnaire.dossiers_filter.termine
end
def suivi
@suivi_class = (@liste == 'suivi' ? 'active' : '')
@suivi ||= current_gestionnaire.dossiers_follow
end
def total_dossiers_per_state
@dossiers_a_traiter_total = waiting_for_gestionnaire.count
@dossiers_en_attente_total = waiting_for_user.count
@dossiers_termine_total = termine.count
@dossiers_suivi_total = suivi.count
def create_dossiers_list_facade liste='a_traiter'
@dossiers_list_facade = DossiersListFacades.new current_gestionnaire, liste
end
def create_dossier_facade dossier_id

View file

@ -0,0 +1,70 @@
class DossiersListFacades
def initialize current_devise_profil, liste
@current_devise_profil = current_devise_profil
@liste = liste
end
def service
@service ||= DossiersListGestionnaireService.new @current_devise_profil, @liste
end
def dossiers_to_display
service.dossiers_to_display
end
def nouveaux_class
(@liste == 'nouveaux' ? 'active' : '')
end
def a_traiter_class
(@liste == 'a_traiter' ? 'active' : '')
end
def en_attente_class
(@liste == 'en_attente' ? 'active' : '')
end
def deposes_class
(@liste == 'deposes' ? 'active' : '')
end
def a_instruire_class
(@liste == 'a_instruire' ? 'active' : '')
end
def termine_class
(@liste == 'termine' ? 'active' : '')
end
def suivi_class
(@liste == 'suivi' ? 'active' : '')
end
def nouveaux_total
service.nouveaux.count
end
def a_traiter_total
service.waiting_for_gestionnaire.count
end
def en_attente_total
service.waiting_for_user.count
end
def deposes_total
service.deposes.count
end
def a_instruire_total
service.a_instruire.count
end
def termine_total
service.termine.count
end
def suivi_total
service.suivi.count
end
end

View file

@ -2,11 +2,15 @@ class Dossier < ActiveRecord::Base
enum state: {draft: 'draft',
initiated: 'initiated',
replied: 'replied',
updated: 'updated',
replied: 'replied', #action utilisateur demandé
updated: 'updated',#etude par l'administration en cours
validated: 'validated',
submitted: 'submitted',
closed: 'closed'}
received: 'received',
closed: 'closed',
refused: 'refused',
without_continuation: 'without_continuation'
}
has_one :etablissement, dependent: :destroy
has_one :entreprise, dependent: :destroy
@ -34,9 +38,12 @@ class Dossier < ActiveRecord::Base
validates :user, presence: true
WAITING_FOR_GESTIONNAIRE = %w(initiated updated submitted)
NOUVEAUX = %w(initiated)
WAITING_FOR_GESTIONNAIRE = %w(updated)
WAITING_FOR_USER = %w(replied validated)
TERMINE = %w(closed)
DEPOSES = %w(submitted)
A_INSTRUIRE = %w(received)
TERMINE = %w(closed refused without_continuation)
def retrieve_last_piece_justificative_by_type(type)
pieces_justificatives.where(type_de_piece_justificative_id: type).last
@ -129,6 +136,10 @@ class Dossier < ActiveRecord::Base
state
end
def nouveaux?
NOUVEAUX.include?(state)
end
def waiting_for_gestionnaire?
WAITING_FOR_GESTIONNAIRE.include?(state)
end
@ -137,10 +148,22 @@ class Dossier < ActiveRecord::Base
WAITING_FOR_USER.include?(state)
end
def deposes?
DEPOSES.include?(state)
end
def a_instruire?
A_INSTRUIRE.include?(state)
end
def termine?
TERMINE.include?(state)
end
def self.nouveaux order = 'ASC'
where(state: NOUVEAUX, archived: false).order("updated_at #{order}")
end
def self.waiting_for_gestionnaire order = 'ASC'
where(state: WAITING_FOR_GESTIONNAIRE, archived: false).order("updated_at #{order}")
end
@ -149,6 +172,14 @@ class Dossier < ActiveRecord::Base
where(state: WAITING_FOR_USER, archived: false).order("updated_at #{order}")
end
def self.deposes order = 'ASC'
where(state: DEPOSES, archived: false).order("updated_at #{order}")
end
def self.a_instruire order = 'ASC'
where(state: A_INSTRUIRE, archived: false).order("updated_at #{order}")
end
def self.termine order = 'ASC'
where(state: TERMINE, archived: false).order("updated_at #{order}")
end

View file

@ -0,0 +1,44 @@
class DossiersListGestionnaireService
def initialize current_devise_profil, liste
@current_devise_profil = current_devise_profil
@liste = liste
end
def dossiers_to_display
{'nouveaux' => nouveaux,
'a_traiter' => waiting_for_gestionnaire,
'en_attente' => waiting_for_user,
'deposes' => deposes,
'a_instruire' => a_instruire,
'termine' => termine,
'suivi' => suivi}[@liste]
end
def nouveaux
@nouveaux ||= @current_devise_profil.dossiers_filter.nouveaux
end
def waiting_for_gestionnaire
@waiting_for_gestionnaire ||= @current_devise_profil.dossiers_filter.waiting_for_gestionnaire
end
def waiting_for_user
@waiting_for_user ||= @current_devise_profil.dossiers_filter.waiting_for_user
end
def deposes
@deposes ||= @current_devise_profil.dossiers_filter.deposes
end
def a_instruire
@a_instruire ||= @current_devise_profil.dossiers_filter.a_instruire
end
def termine
@termine ||= @current_devise_profil.dossiers_filter.termine
end
def suivi
@suivi ||= @current_devise_profil.dossiers_follow
end
end

View file

@ -3,33 +3,47 @@
#onglets
%ul.nav.nav-tabs
%li{ class: (@a_traiter_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'a_traiter')}"}
%h5.text-danger
= "À traiter "
.badge.progress-bar-danger
=@dossiers_a_traiter_total
%li{ class: (@en_attente_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'en_attente')}"}
%li{ class: (@dossiers_list_facade.nouveaux_class)}
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'nouveaux')}", 'data-toggle' => :tooltip, title: 'Les nouveaux dossiers non ouverts.'}
%h5.text-info
="En attente "
= "Nouveaux "
.badge.progress-bar-info
=@dossiers_en_attente_total
=@dossiers_list_facade.nouveaux_total
%li{ class: (@suivi_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'suivi')}"}
%li{ class: (@dossiers_list_facade.a_traiter_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'a_traiter')}", 'data-toggle' => :tooltip, title: 'Les dossiers qui requièrent une action de votre part.'}
%h5.text-danger
= "Action requise"
.badge.progress-bar-danger
=@dossiers_list_facade.a_traiter_total
%li{ class: (@dossiers_list_facade.en_attente_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'en_attente')}", 'data-toggle' => :tooltip, title: 'Les dossiers en attentes d\'une action de la part de l\'usager.'}
%h5.text-default
="Attente usager "
.badge.progress-bar-default
=@dossiers_list_facade.en_attente_total
%li{ class: (@dossiers_list_facade.deposes_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'deposes')}", 'data-toggle' => :tooltip, title: 'Les dossiers qui ont été validés et déposés par les usager qui attendent une réponse de bonne réception avant instruction.'}
%h5.text-purple
="À réceptionner"
.badge.progress-bar-purple
=@dossiers_list_facade.deposes_total
%li{ class: (@dossiers_list_facade.a_instruire_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'a_instruire')}", 'data-toggle' => :tooltip, title: 'Les dossiers qui ont été notifiés comme bien réceptionnés et qui attendent un verdict final.'}
%h5.text-warning
="Suivi"
= "À instruire"
.badge.progress-bar-warning
=@dossiers_suivi_total
=@dossiers_list_facade.a_instruire_total
%li{ class: (@termine_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'termine')}"}
%li{ class: (@dossiers_list_facade.termine_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'termine')}",'data-toggle' => :tooltip, title: 'Tous les dossiers qui ont été traité avec un statut "Validé", "Refusé" ou "Sans suite "'}
%h5.text-success
= "Terminé"
.badge.progress-bar-success
=@dossiers_termine_total
=@dossiers_list_facade.termine_total
%ul.nav.nav-tabs.navbar-right{style:'border-bottom: none;'}
%li#search{class: "#{'active' unless @dossiers_search.nil?}"}
@ -46,5 +60,4 @@
%a.btn#pref_list_dossier_open_action{href: '#'}
%i.fa.fa-columns
%br

View file

@ -41,7 +41,7 @@
%br
.row{style: 'text-align:right'}
- if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed?
- if !@facade.dossier.validated? && !@facade.dossier.received? && !@facade.dossier.submitted? && !@facade.dossier.closed? && !@facade.dossier.refused? && !@facade.dossier.without_continuation?
- if user_signed_in? && (current_user.email == @facade.dossier.user.email)
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0
%a.btn.btn-success{"data-target" => "#UploadPJmodal",
@ -60,7 +60,7 @@
= 'Modifier mon dossier'
-if gestionnaire_signed_in?
-if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed?
-if !@facade.dossier.validated? && !@facade.dossier.received? && !@facade.dossier.submitted? && !@facade.dossier.closed? && !@facade.dossier.refused? && !@facade.dossier.without_continuation?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Valider le dossier'

View file

@ -9,12 +9,15 @@ fr:
date_previsionnelle: "La date de début prévisionnelle"
state:
draft: "Brouillon"
initiated: "Soumis"
initiated: "Nouveau"
replied: "Répondu"
updated: "Mis à jour"
validated: "Validé"
validated: "Figé"
submitted: "Déposé"
closed: "Traité"
received: "Reçu"
closed: "Accepté"
refused: "Refusé"
without_continuation: "Sans suite"
errors:
models:

View file

@ -19,7 +19,7 @@ describe DossierDecorator do
it 'initiated is initiate' do
dossier.initiated!
expect(subject).to eq('Soumis')
expect(subject).to eq('Nouveau')
end
it 'replied is repondu' do
@ -34,7 +34,7 @@ describe DossierDecorator do
it 'validated is valide' do
dossier.validated!
expect(subject).to eq('Validé')
expect(subject).to eq('Figé')
end
it 'submitted is dépose' do
@ -44,7 +44,22 @@ describe DossierDecorator do
it 'closed is traité' do
dossier.closed!
expect(subject).to eq('Traité')
expect(subject).to eq('Accepté')
end
it 'received is reçu' do
dossier.received!
expect(subject).to eq('Reçu')
end
it 'without_continuation is traité' do
dossier.without_continuation!
expect(subject).to eq('Sans suite')
end
it 'refused is traité' do
dossier.refused!
expect(subject).to eq('Refusé')
end
end
end

View file

@ -10,6 +10,7 @@ describe AdminProceduresShowFacades do
let!(:dossier_4) { create(:dossier, procedure: procedure, archived: true, state: 'validated') }
let!(:dossier_5) { create(:dossier, procedure: procedure, archived: true, state: 'validated') }
let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'initiated') }
let!(:dossier_7) { create(:dossier, procedure: procedure, state: 'updated') }
subject { AdminProceduresShowFacades.new procedure }
@ -22,13 +23,13 @@ describe AdminProceduresShowFacades do
describe '.dossiers' do
subject { super().dossiers }
it { expect(subject.size).to eq(6) }
it { expect(subject.size).to eq(7) }
end
describe '.dossiers_for_pie_highchart' do
subject { super().dossiers_for_pie_highchart }
it { expect(subject).to eq({'Soumis' => 1, 'Validé' => 2}) }
it { expect(subject).to eq({'Nouveau' => 1, 'Figé' => 2, "Mis à jour"=>1}) }
end
describe '.dossiers_archived_by_state_total' do
@ -52,7 +53,7 @@ describe AdminProceduresShowFacades do
describe 'dossiers_total' do
subject { super().dossiers_total }
it { is_expected.to eq(6) }
it { is_expected.to eq(7) }
end
describe 'dossiers_waiting_gestionnaire_total' do

View file

@ -7,7 +7,7 @@ feature 'usage of pref list dossier lateral panel', js: true do
let(:procedure) { create(:procedure, administrateur: administrateur) }
before do
create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated')
create(:dossier, :with_entreprise, procedure: procedure, state: 'updated')
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
visit backoffice_path
end

View file

@ -5,7 +5,7 @@ feature 'on backoffice page' do
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') }
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
@ -17,12 +17,14 @@ feature 'on backoffice page' do
before do
page.find_by_id(:gestionnaire_email).set gestionnaire.email
page.find_by_id(:gestionnaire_password).set gestionnaire.password
page.click_on 'Se connecter'
end
context 'when he click on first dossier' do
before do
page.click_on dossier.id
end
scenario 'it redirect to dossier page' do
expect(page).to have_css('#backoffice_dossier_show')
end

View file

@ -9,10 +9,21 @@ feature 'on click on tabs button' do
end
context 'when gestionnaire is logged in' do
context 'when he click on tabs a traitee' do
context 'when he click on tabs nouveaux' do
before do
visit backoffice_dossiers_url(liste: :nouveaux)
page.click_on 'Nouveaux 0'
end
scenario 'it redirect to backoffice dossier termine' do
expect(page).to have_css('#backoffice_index')
end
end
context 'when he click on tabs a traite' do
before do
visit backoffice_dossiers_url(liste: :a_traiter)
page.click_on 'À traiter 0'
page.click_on 'Action requise 0'
end
scenario 'it redirect to backoffice dossier termine' do
@ -23,7 +34,7 @@ feature 'on click on tabs button' do
context 'when he click on tabs en attente' do
before do
visit backoffice_dossiers_url(liste: :en_attente)
page.click_on 'En attente 0'
page.click_on 'Attente usager 0'
end
scenario 'it redirect to backoffice dossier en attente' do
@ -31,6 +42,28 @@ feature 'on click on tabs button' do
end
end
context 'when he click on tabs a receptionner' do
before do
visit backoffice_dossiers_url(liste: :nouveaux)
page.click_on 'À réceptionner 0'
end
scenario 'it redirect to backoffice dossier a_receptionner' do
expect(page).to have_css('#backoffice_index')
end
end
context 'when he click on tabs a instruire' do
before do
visit backoffice_dossiers_url(liste: :a_instruire)
page.click_on 'À instruire 0'
end
scenario 'it redirect to backoffice dossier termine' do
expect(page).to have_css('#backoffice_index')
end
end
context 'when he click on tabs termine' do
before do
visit backoffice_dossiers_url(liste: :termine)

View file

@ -387,25 +387,36 @@ describe Dossier do
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_admin
create(:dossier, procedure: procedure_admin, state: 'draft')
create(:dossier, procedure: procedure_admin, state: 'initiated') #nouveaux
create(:dossier, procedure: procedure_admin, state: 'initiated') #nouveaux
create(:dossier, procedure: procedure_admin, state: 'replied') #en_attente
create(:dossier, procedure: procedure_admin, state: 'updated') #a_traiter
create(:dossier, procedure: procedure_admin, state: 'submitted') #deposes
create(:dossier, procedure: procedure_admin, state: 'received') #a_instruire
create(:dossier, procedure: procedure_admin, state: 'received') #a_instruire
create(:dossier, procedure: procedure_admin, state: 'closed') #termine
create(:dossier, procedure: procedure_admin, state: 'refused') #termine
create(:dossier, procedure: procedure_admin, state: 'without_continuation') #termine
create(:dossier, procedure: procedure_admin_2, state: 'validated') #en_attente
create(:dossier, procedure: procedure_admin_2, state: 'submitted') #deposes
create(:dossier, procedure: procedure_admin_2, state: 'closed') #termine
create(:dossier, procedure: procedure_admin, state: 'initiated', archived: true) #a_traiter #archived
create(:dossier, procedure: procedure_admin, state: 'replied', archived: true) #en_attente #archived
create(:dossier, procedure: procedure_admin, state: 'closed', archived: true) #termine #archived
end
let!(:dossier1) { create(:dossier, procedure: procedure_admin, state: 'draft') }
let!(:dossier2) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
let!(:dossier3) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
let!(:dossier4) { create(:dossier, procedure: procedure_admin, state: 'replied') } #en_attente
let!(:dossier5) { create(:dossier, procedure: procedure_admin, state: 'updated') } #a_traiter
let!(:dossier6) { create(:dossier, procedure: procedure_admin_2, state: 'validated') } #en_attente
let!(:dossier7) { create(:dossier, procedure: procedure_admin_2, state: 'submitted') } #a_traiter
let!(:dossier8) { create(:dossier, procedure: procedure_admin_2, state: 'closed') } #termine
let!(:dossier9) { create(:dossier, procedure: procedure_admin, state: 'closed') } #termine
let!(:dossier10) { create(:dossier, procedure: procedure_admin, state: 'initiated', archived: true) } #a_traiter #archived
let!(:dossier11) { create(:dossier, procedure: procedure_admin, state: 'replied', archived: true) } #en_attente #archived
let!(:dossier12) { create(:dossier, procedure: procedure_admin, state: 'closed', archived: true) } #termine #archived
describe '#nouveaux' do
subject { gestionnaire.dossiers.nouveaux }
it { expect(subject.size).to eq(2) }
end
describe '#waiting_for_gestionnaire' do
subject { gestionnaire.dossiers.waiting_for_gestionnaire }
it { expect(subject.size).to eq(3) }
it { expect(subject.size).to eq(1) }
end
describe '#waiting_for_user' do
@ -414,10 +425,22 @@ describe Dossier do
it { expect(subject.size).to eq(1) }
end
describe '#a_instruire' do
subject { gestionnaire.dossiers.a_instruire }
it { expect(subject.size).to eq(2) }
end
describe '#deposes' do
subject { gestionnaire.dossiers.deposes }
it { expect(subject.size).to eq(1) }
end
describe '#termine' do
subject { gestionnaire.dossiers.termine }
it { expect(subject.size).to eq(1) }
it { expect(subject.size).to eq(3) }
end
end

View file

@ -8,12 +8,23 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated').decorate }
let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, procedure: procedure, state: 'replied').decorate }
let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated').decorate }
let!(:decorate_dossier_validated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'validated').decorate }
let!(:decorate_dossier_submitted) { create(:dossier, :with_entreprise, procedure: procedure, state: 'submitted').decorate }
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, procedure: procedure, state: 'received').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate }
let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refused').decorate }
let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'without_continuation').decorate }
before do
decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plip')
decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plop')
decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plap')
decorate_dossier_updated.entreprise.update_column(:raison_sociale, 'plep')
decorate_dossier_validated.entreprise.update_column(:raison_sociale, 'plip')
decorate_dossier_submitted.entreprise.update_column(:raison_sociale, 'plop')
decorate_dossier_received.entreprise.update_column(:raison_sociale, 'plup')
decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plyp')
decorate_dossier_refused.entreprise.update_column(:raison_sociale, 'plzp')
decorate_dossier_without_continuation.entreprise.update_column(:raison_sociale, 'plnp')
create :preference_list_dossier,
gestionnaire: gestionnaire,
@ -43,119 +54,120 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
sign_in gestionnaire
end
describe 'on tab a_traiter' do
shared_examples 'check_tab_content' do
before do
assign :dossiers_list_facade, (DossiersListFacades.new gestionnaire, liste)
assign(:dossiers, (smart_listing_create :dossiers,
gestionnaire.dossiers.waiting_for_gestionnaire,
dossiers_to_display,
partial: "backoffice/dossiers/list",
array: true))
assign(:liste, 'a_traiter')
assign(:a_traiter_class, 'active')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_initiated.entreprise.raison_sociale) }
it { is_expected.to have_content(decorate_dossier_initiated.display_state) }
it { is_expected.to have_content(decorate_dossier_initiated.last_update) }
it { is_expected.not_to have_content(decorate_dossier_replied.entreprise.raison_sociale) }
it { is_expected.not_to have_content(decorate_dossier_closed.entreprise.raison_sociale) }
describe 'pref list column' do
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_at_check.entreprise.raison_sociale) }
it { is_expected.to have_content(decorate_dossier_at_check.display_state) }
it { is_expected.to have_content(decorate_dossier_at_check.last_update) }
end
it { is_expected.to have_css("#suivre_dossier_#{gestionnaire.dossiers.waiting_for_gestionnaire.first.id}") }
it { is_expected.to have_css("#suivre_dossier_#{dossiers_to_display.first.id}") }
it { expect(dossiers_to_display.count).to eq total_dossiers }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-danger') }
it { is_expected.to have_selector(active_class) }
end
end
describe 'on tab nouveaux' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-info' }
let(:dossiers_to_display) { gestionnaire.dossiers.nouveaux }
let(:liste) { 'nouveaux' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_initiated }
end
end
describe 'on tab a_traiter' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-danger' }
let(:dossiers_to_display) { gestionnaire.dossiers.waiting_for_gestionnaire }
let(:liste) { 'a_traiter' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_updated }
end
end
describe 'on tab en_attente' do
before do
assign(:dossiers, (smart_listing_create :dossiers,
gestionnaire.dossiers.waiting_for_user,
partial: "backoffice/dossiers/list",
array: true))
assign(:liste, 'en_attente')
assign(:en_attente_class, 'active')
let(:total_dossiers) { 2 }
let(:active_class) { '.active .text-default' }
let(:dossiers_to_display) { gestionnaire.dossiers.waiting_for_user }
let(:liste) { 'en_attente' }
render
describe 'for state replied' do
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_replied }
end
end
subject { rendered }
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_replied.entreprise.raison_sociale) }
it { is_expected.to have_content(decorate_dossier_replied.display_state) }
it { is_expected.to have_content(decorate_dossier_replied.last_update) }
it { is_expected.not_to have_content(decorate_dossier_initiated.entreprise.raison_sociale) }
it { is_expected.not_to have_content(decorate_dossier_closed.entreprise.raison_sociale) }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-info') }
describe 'for state validated' do
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_validated }
end
end
end
describe 'on tab suivi' do
before do
create :follow, dossier_id: decorate_dossier_replied.id, gestionnaire_id: gestionnaire.id
describe 'on tab deposes' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-purple' }
let(:dossiers_to_display) { gestionnaire.dossiers.deposes }
let(:liste) { 'deposes' }
assign(:dossiers, (smart_listing_create :dossiers,
gestionnaire.dossiers_follow,
partial: "backoffice/dossiers/list",
array: true))
assign(:suivi_class, 'active')
assign(:liste, 'suivi')
render
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_submitted }
end
end
subject { rendered }
describe 'on tab a_instruire' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-warning' }
let(:dossiers_to_display) { gestionnaire.dossiers.a_instruire }
let(:liste) { 'a_instruire' }
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_replied.entreprise.raison_sociale) }
it { is_expected.to have_content(decorate_dossier_replied.display_state) }
it { is_expected.to have_content(decorate_dossier_replied.last_update) }
it { is_expected.not_to have_content(decorate_dossier_initiated.entreprise.raison_sociale) }
it { is_expected.not_to have_content(decorate_dossier_closed.entreprise.raison_sociale) }
it { is_expected.to have_css("#suivre_dossier_#{gestionnaire.dossiers_follow.first.id}") }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-warning') }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_received }
end
end
describe 'on tab termine' do
before do
assign(:dossiers, (smart_listing_create :dossiers,
gestionnaire.dossiers.termine,
partial: "backoffice/dossiers/list",
array: true))
assign(:termine_class, 'active')
assign(:liste, 'termine')
render
let(:total_dossiers) { 3 }
let(:active_class) { '.active .text-success' }
let(:dossiers_to_display) { gestionnaire.dossiers.termine }
let(:liste) { 'termine' }
describe 'for state closed' do
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_closed }
end
end
subject { rendered }
describe 'for state refused' do
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_refused }
end
end
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_closed.entreprise.raison_sociale) }
it { is_expected.to have_content(decorate_dossier_closed.display_state) }
it { is_expected.to have_content(decorate_dossier_closed.last_update) }
it { is_expected.not_to have_content(decorate_dossier_initiated.entreprise.raison_sociale) }
it { is_expected.not_to have_content(decorate_dossier_replied.entreprise.raison_sociale) }
it { is_expected.to have_css("#suivre_dossier_#{gestionnaire.dossiers.termine.first.id}") }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-success') }
describe 'for state without_continuation' do
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_without_continuation }
end
end
end
end

View file

@ -57,7 +57,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
render
end
it { expect(rendered).to have_content('Soumis') }
it { expect(rendered).to have_content('Nouveau') }
it 'button Valider le dossier is present' do
expect(rendered).to have_css('#action_button')
@ -102,7 +102,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
render
end
it { expect(rendered).to have_content('Validé') }
it { expect(rendered).to have_content('Figé') }
it 'button Valider le dossier is not present' do
expect(rendered).not_to have_css('#action_button')
@ -136,7 +136,52 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
render
end
it { expect(rendered).to have_content('Traité') }
it { expect(rendered).to have_content('Accepté') }
it 'button Valider le dossier is not present' do
expect(rendered).not_to have_css('#action_button')
expect(rendered).not_to have_content('Valider le dossier')
end
end
context 'when dossier have state received' do
let(:state) { 'received' }
before do
render
end
it { expect(rendered).to have_content('Reçu') }
it 'button Valider le dossier is not present' do
expect(rendered).not_to have_css('#action_button')
expect(rendered).not_to have_content('Valider le dossier')
end
end
context 'when dossier have state without_continuation' do
let(:state) { 'without_continuation' }
before do
render
end
it { expect(rendered).to have_content('Sans suite') }
it 'button Valider le dossier is not present' do
expect(rendered).not_to have_css('#action_button')
expect(rendered).not_to have_content('Valider le dossier')
end
end
context 'when dossier have state refused' do
let(:state) { 'refused' }
before do
render
end
it { expect(rendered).to have_content('Refusé') }
it 'button Valider le dossier is not present' do
expect(rendered).not_to have_css('#action_button')

View file

@ -75,10 +75,11 @@ describe 'users/dossiers/index.html.haml', type: :view do
it { is_expected.to have_css('#users_index') }
describe 'dossier initiated is present' do
it { is_expected.to have_content(dossier.procedure.libelle) }
it { is_expected.to have_content(dossier.entreprise.raison_sociale) }
it { is_expected.to have_content(dossier.display_state) }
it { is_expected.to have_content(dossier.last_update) }
pending
# it { is_expected.to have_content(dossier.procedure.libelle) }
# it { is_expected.to have_content(dossier.entreprise.raison_sociale) }
# it { is_expected.to have_content(dossier.display_state) }
# it { is_expected.to have_content(dossier.last_update) }
end
describe 'dossier replied and closed are not present' do

View file

@ -59,7 +59,7 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
render
end
it { expect(rendered).to have_content('Soumis') }
it { expect(rendered).to have_content('Nouveau') }
it 'button Modifier les document est present' do
expect(rendered).to have_content('Modifier les documents')
@ -125,13 +125,41 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
end
context 'when dossier state is traité' do
context 'when dossier state is closed' do
let(:state) { 'closed' }
before do
render
end
it { expect(rendered).to have_content('Traité') }
it { expect(rendered).to have_content('Accepté') }
it 'button Editer mon dossier n\'est plus present' do
expect(rendered).not_to have_css('#maj_infos')
expect(rendered).not_to have_content('Modifier mon dossier')
end
end
context 'when dossier state is refused' do
let(:state) { 'refused' }
before do
render
end
it { expect(rendered).to have_content('Refusé') }
it 'button Editer mon dossier n\'est plus present' do
expect(rendered).not_to have_css('#maj_infos')
expect(rendered).not_to have_content('Modifier mon dossier')
end
end
context 'when dossier state is without_continuation' do
let(:state) { 'without_continuation' }
before do
render
end
it { expect(rendered).to have_content('Sans suite') }
it 'button Editer mon dossier n\'est plus present' do
expect(rendered).not_to have_css('#maj_infos')