Merge branch 'develop' into list_dossiers_archived

This commit is contained in:
Mathieu Magnin 2017-03-01 10:35:20 +01:00 committed by GitHub
commit 87865fcf1b
55 changed files with 120 additions and 683 deletions

View file

@ -2,8 +2,6 @@
font-family: Arial;
.show-block {
width: 840px;
min-width: 840px;
margin-left: auto;
margin-right: auto;
box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.5);

View file

@ -34,7 +34,7 @@
}
}
#navbar-body {
height: 60px;
min-height: 60px;
background-color: #FFFFFF;
box-shadow: 0 1px 2px 0 rgba(50,50,50,0.5);
padding-left: 50px;
@ -43,7 +43,7 @@
font-size: 18px;
font-weight: bold;
line-height: 58px;
height: 58px;
min-height: 58px;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
@ -56,7 +56,7 @@
color: #666666;
padding: 8px;
border-right: 1px solid #C8C6C8;
height: 60px;
min-height: 60px;
.dropdown-toggle {
cursor: pointer;
}
@ -84,12 +84,8 @@
#sign_in{
margin-top: 7px;
.btn {
color: #003C92;
float: right;
margin-right: 1.3em;
}
.btn:hover {
color: #668ABD;
margin-right: 15px;
}
}

View file

@ -85,21 +85,10 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
default_sort: dossiers_list_facade.service.default_sort
end
def valid
create_dossier_facade params[:dossier_id]
@facade.dossier.next_step! 'gestionnaire', 'valid'
flash.notice = 'Dossier confirmé avec succès.'
NotificationMailer.dossier_validated(@facade.dossier).deliver_now!
redirect_to backoffice_dossier_path(id: @facade.dossier.id)
end
def receive
create_dossier_facade params[:dossier_id]
@facade.dossier.next_step! 'gestionnaire', 'receive'
@facade.dossier.received!
flash.notice = 'Dossier considéré comme reçu.'
NotificationMailer.dossier_received(@facade.dossier).deliver_now!
@ -170,6 +159,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
redirect_to backoffice_dossiers_path
end
def unarchive
@dossier = Dossier.find(params[:id])
if @dossier.archived
@ -178,6 +168,15 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
end
redirect_to backoffice_dossier_path(@dossier)
end
def reopen
create_dossier_facade params[:dossier_id]
@facade.dossier.initiated!
flash.notice = 'Dossier réouvert.'
redirect_to backoffice_dossiers_path
end
private

View file

@ -17,18 +17,9 @@ class Users::RecapitulatifController < UsersController
redirect_to users_dossier_recapitulatif_path
end
def submit
create_dossier_facade
@facade.dossier.submit!
flash.notice = 'Dossier déposé avec succès.'
redirect_to users_dossier_recapitulatif_path
end
def self.route_authorization
{
states: [:initiated, :replied, :updated, :validated, :received, :submitted, :without_continuation, :closed, :refused]
states: [:initiated, :replied, :updated, :received, :without_continuation, :closed, :refused]
}
end

View file

@ -5,8 +5,6 @@ class MailTemplateDecorator < Draper::Decorator
case object.type
when "MailReceived"
"E-mail d'accusé de réception"
when "MailValidated"
"E-mail de validation"
else
object.type
end

View file

@ -7,10 +7,6 @@ class NotificationMailer < ApplicationMailer
send_mail dossier, dossier.procedure.mail_received.object_for_dossier(dossier)
end
def dossier_validated dossier
send_mail dossier, dossier.procedure.mail_validated.object_for_dossier(dossier)
end
def dossier_submitted dossier
send_mail dossier, "Votre dossier TPS N°#{dossier.id} a été déposé"
end

View file

@ -5,8 +5,6 @@ class Dossier < ActiveRecord::Base
initiated: 'initiated',
replied: 'replied', #action utilisateur demandé
updated: 'updated', #etude par l'administration en cours
validated: 'validated',
submitted: 'submitted',
received: 'received',
closed: 'closed',
refused: 'refused',
@ -42,7 +40,6 @@ class Dossier < ActiveRecord::Base
after_save :build_default_champs, if: Proc.new { procedure_id_changed? }
after_save :build_default_individual, if: Proc.new { procedure.for_individual? }
after_save :internal_notification
validates :user, presence: true
@ -50,14 +47,12 @@ class Dossier < ActiveRecord::Base
NOUVEAUX = %w(initiated)
OUVERT = %w(updated replied)
WAITING_FOR_GESTIONNAIRE = %w(updated)
WAITING_FOR_USER = %w(replied validated)
WAITING_FOR_USER = %w(replied)
EN_CONSTRUCTION = %w(initiated updated replied)
VALIDES = %w(validated)
DEPOSES = %w(submitted)
EN_INSTRUCTION = %w(submitted received)
EN_INSTRUCTION = %w(received)
A_INSTRUIRE = %w(received)
TERMINE = %w(closed refused without_continuation)
ALL_STATE = %w(initiated updated replied validated submitted received closed refused without_continuation)
ALL_STATE = %w(initiated updated replied received closed refused without_continuation)
def unreaded_notifications
@unreaded_notif ||= notifications.where(already_read: false)
@ -108,7 +103,7 @@ class Dossier < ActiveRecord::Base
end
def next_step! role, action
unless %w(initiate follow update comment valid submit receive refuse without_continuation close).include?(action)
unless %w(initiate follow update comment receive refuse without_continuation close).include?(action)
fail 'action is not valid'
end
@ -122,10 +117,6 @@ class Dossier < ActiveRecord::Base
if draft?
initiated!
end
when 'submit'
if validated?
submitted!
end
when 'update'
if replied?
updated!
@ -147,18 +138,6 @@ class Dossier < ActiveRecord::Base
if initiated?
updated!
end
when 'valid'
if updated?
validated!
elsif replied?
validated!
elsif initiated?
validated!
end
when 'receive'
if submitted?
received!
end
when 'close'
if received?
closed!
@ -208,18 +187,6 @@ class Dossier < ActiveRecord::Base
where(state: OUVERT, archived: false).order("updated_at #{order}")
end
def self.valides order = 'ASC'
where(state: VALIDES, archived: false).order("updated_at #{order}")
end
def self.fige order = 'ASC'
where(state: VALIDES, 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
@ -326,15 +293,8 @@ class Dossier < ActiveRecord::Base
follows.size
end
def submit!
self.deposit_datetime= DateTime.now
next_step! 'user', 'submit'
NotificationMailer.dossier_submitted(self).deliver_now!
end
def read_only?
validated? || received? || submitted? || closed? || refused? || without_continuation?
received? || closed? || refused? || without_continuation?
end
def owner? email
@ -344,12 +304,4 @@ class Dossier < ActiveRecord::Base
def invite_by_user? email
(invites_user.pluck :email).include? email
end
private
def internal_notification
if state_changed? && state == 'submitted'
NotificationService.new('submitted', self.id).notify
end
end
end

View file

@ -1,18 +0,0 @@
class MailValidated < MailTemplate
before_save :default_values
def default_values
self.object ||= "[TPS] Votre dossier TPS N°--numero_dossier-- a été validé"
self.body ||= "Bonjour,<br>
<br>
Votre dossier N°--numero_dossier-- est prêt à être déposé pour instruction.<br>
<br>
Afin de finaliser son dépôt, merci de vous rendre sur --lien_dossier--.,<br>
<br>
Bonne journée,<br>
---<br>
Merci de ne pas répondre à ce mail. Postez directement vos questions dans votre dossier sur la plateforme.<br>
---<br>
L'équipe TPS"
end
end

View file

@ -5,7 +5,6 @@ class Procedure < ActiveRecord::Base
has_many :dossiers
has_many :mail_templates
has_one :mail_received
has_one :mail_validated
has_one :procedure_path, dependent: :destroy
@ -34,7 +33,6 @@ class Procedure < ActiveRecord::Base
def build_default_mails
MailReceived.create(procedure: self) unless mail_received
MailValidated.create(procedure: self) unless mail_validated
end
def path

View file

@ -8,10 +8,7 @@ class DossiersListGestionnaireService
def dossiers_to_display
@dossiers_to_display ||=
{'nouveaux' => nouveaux,
# 'suivi' => suivi,
'a_traiter' => ouvert,
'fige' => fige,
'deposes' => deposes,
'a_instruire' => a_instruire,
'termine' => termine,
'archive' => archive,
@ -20,7 +17,7 @@ class DossiersListGestionnaireService
end
def self.dossiers_liste_libelle
['nouveaux', 'suivi', 'a_traiter', 'fige', 'deposes', 'a_instruire', 'termine', 'all_state']
['nouveaux', 'suivi', 'a_traiter', 'a_instruire', 'termine', 'all_state']
end
def all_state
@ -39,14 +36,6 @@ class DossiersListGestionnaireService
@ouvert ||= filter_dossiers.ouvert
end
def fige
@fige ||= filter_dossiers.fige
end
def deposes
@deposes ||= filter_dossiers.deposes
end
def a_instruire
@a_instruire ||= filter_dossiers.a_instruire
end

View file

@ -7,7 +7,6 @@ class DossiersListUserService
def dossiers_to_display
{'brouillon' => brouillon,
'a_traiter' => en_construction,
'valides' => valides,
'en_instruction' => en_instruction,
'termine' => termine,
'invite' => invite,
@ -15,7 +14,7 @@ class DossiersListUserService
end
def self.dossiers_liste_libelle
['brouillon', 'a_traiter', 'valides', 'en_instruction', 'termine', 'invite', 'all_state']
['brouillon', 'a_traiter', 'en_instruction', 'termine', 'invite', 'all_state']
end
def all_state
@ -34,10 +33,6 @@ class DossiersListUserService
@invite ||= @current_devise_profil.invites
end
def valides
@valides ||= @current_devise_profil.dossiers.valides
end
def en_instruction
@en_instruction ||= @current_devise_profil.dossiers.en_instruction
end

View file

@ -22,7 +22,6 @@
- MailTemplate::TAGS.each do |balise|
%tr
%td.center
%b.text-success
= "--#{balise.first}--"
= "--#{balise.first}--"
%td
=balise.second[:description]

View file

@ -1,2 +1,2 @@
.col-xs-12#backoffice_dossier_show
= render partial: "dossiers/dossier_show"
#backoffice_dossier_show.col-xs-12
= render partial: "dossiers/dossier_show"

View file

@ -1,4 +1,4 @@
%div#main-container{class: "col-lg-#{main_container_size} col-md-#{main_container_size}"}
%div#main-container{class: "col-xs-#{main_container_size}"}
%div.row
= render partial: 'layouts/flash_messages'
%div.row

View file

@ -1,14 +1,14 @@
%div.col-lg-2.col-md-2.col-sm-2.col-xs-2
.col-xs-2
%a#title_navbar{href: '/'}
%div.row#home
%div.col-lg-6.no-padding
.row#home
.col-lg-6.no-padding
= image_tag('marianne_small.png', class: 'logo')
%div.col-lg-6.no-padding#tps-title
.col-lg-6.no-padding#tps-title
TPS
%div.col-lg-10.col-md-10.col-sm-10.col-xs-10.no-padding
%div#navbar-body
%div.row
.col-xs-10.no-padding
#navbar-body
.row
-begin
= render partial: @navbar_url
-rescue

View file

@ -4,14 +4,9 @@
#action-block
- if gestionnaire_signed_in?
- if !@facade.dossier.read_only?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button.action{'data-toggle' => :tooltip, title: 'En cliquant ici, vous figez le dossier et autorisez le dépôt du dossier pour instruction.'}
= 'Déclarer complet'.upcase
- elsif @facade.dossier.submitted?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :receive, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button.action
= 'Accuser réception'.upcase
- if !@facade.dossier.read_only? || @facade.dossier.initiated?
= link_to 'Accuser réception', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block'
- elsif @facade.dossier.received?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Accepter') do
%button.action.close-dossier
@ -22,6 +17,7 @@
= form_tag(url_for({controller: 'backoffice/dossiers', action: :refuse, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Refuser') do
%button.action.refuse-dossier
%i.fa.fa-times
= link_to 'Reouvrir', backoffice_dossier_reopen_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block'
%hr
- if @facade.dossier.archived?

View file

@ -23,12 +23,6 @@
.badge.progress-bar-danger
= @dossiers_list_facade.en_construction_total
%a{:href => "#{url_for users_dossiers_path(liste: 'valides')}", 'data-toggle' => :tooltip, title: 'Les dossiers relus par votre accompagnateur pouvant être déposés pour examen.'}
%div.procedure_list_element{ class: @dossiers_list_facade.valides_class, id: 'valides' }
="À déposer"
.badge.progress-bar-purple
= @dossiers_list_facade.valides_total
%a{:href => "#{url_for users_dossiers_path(liste: 'en_instruction')}", 'data-toggle' => :tooltip, title: 'Les dossiers en cours d\'examen par l\'administration compétante.'}
%div.procedure_list_element{ class: @dossiers_list_facade.en_instruction_class, id: 'en_instruction' }
="En examen"

View file

@ -4,11 +4,6 @@
%div.infos
%div= t('dynamics.dossiers.numéro') + @facade.dossier.id.to_s
%div#action-block
- if @facade.dossier.validated? && @facade.dossier.user == current_user
= form_tag(url_for({controller: 'users/recapitulatif', action: :submit, dossier_id: @facade.dossier.id}), method: 'POST') do
%button#validate_button.action= 'Procéder au dépôt définitif'
%div#menu-block
%div#infos-block

View file

@ -1,6 +1,6 @@
%div.col-lg-8.col-md-8.col-sm-8.col-xs-8.main-info
.col-xs-7.main-info
%div.col-lg-3.col-md-3.col-sm-3.col-xs-3.options
.col-xs-3.options
%div{ style: "decorate:none; display: flex;box-shadow:none; float:right; display: flex; margin-top: 5px" }
%div{ style: "vertical-align: middle; margin-right: 10px; margin-top: auto; margin-bottom: auto;" }
= current_administrateur.email

View file

@ -1,4 +1,4 @@
%div.col-lg-8.col-md-8.col-sm-8.col-xs-8.main-info
.col-xs-7.main-info
= @facade_data_view.procedure_id.nil? ? "Tous les dossiers" : @facade_data_view.procedure.libelle
%div.col-lg-3.col-md-3.col-sm-3.col-xs-3.options
%div.row

View file

@ -1,9 +1,9 @@
%div.col-lg-8.col-md-8.col-sm-8.col-xs-8.main-info
.col-xs-7.main-info
%span{ 'data-toggle' => :tooltip, "data-placement" => :bottom, title: @facade.dossier.procedure.libelle }
= @facade.dossier.procedure.libelle
%div.col-lg-3.col-md-3.col-sm-3.col-xs-3.options
%div.row
%div.col-lg-12.col-md-12.col-sm-12.col-xs-12
.col-xs-3.options
.row
.col-xs-12
- if current_gestionnaire.follow?(@facade.dossier.id)
= link_to backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), "data-method" => :put, class: "button-navbar-action",id: "suivre_dossier_#{@facade.dossier.id}" do
%i.fa.fa-user-times
@ -12,14 +12,14 @@
= link_to backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), 'data-method' => :put, class: 'button-navbar-action', id: "suivre_dossier_#{@facade.dossier.id}" do
%i.fa.fa-user-plus
Suivre le dossier
%div.row
%div.col-lg-12.col-md-12.col-sm-12.col-xs-12
%div#invitations.dropdown-toggle{ 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false }
.row
.col-xs-12
#invitations.dropdown-toggle{ 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false }
%i.fa.fa-user
= t('utils.involved')
.badge.progress-bar-info
= @facade.dossier.invites.count
%div.dropdown-menu.dropdown-menu-right.dropdown-pannel
.dropdown-menu.dropdown-menu-right.dropdown-pannel
%h4= t('dynamics.dossiers.followers.title')
%ul
- unless @facade.followers.empty?

View file

@ -1,17 +1,15 @@
-#%span.fa.fa-sign-out
-if user_signed_in?
.col-lg-1.col-md-1.col-sm-1.col-xs-1#sign_out.no-padding
#sign_out.col-xs-2.no-padding
= render partial: 'users/login_banner'
= render partial: 'layouts/credentials'
-elsif gestionnaire_signed_in?
.col-lg-1.col-md-1.col-sm-1.col-xs-1#sign_out.no-padding
#sign_out.col-xs-2.no-padding
= render partial: 'gestionnaires/login_banner'
= render partial: 'layouts/credentials'
-elsif administrateur_signed_in?
.col-lg-1.col-md-1.col-sm-1.col-xs-1#sign_out.no-padding
#sign_out.col-xs-2.no-padding
= render partial: 'administrateurs/login_banner'
= render partial: 'layouts/credentials'
-else
.col-lg-1.col-md-1.col-sm-1.col-xs-1#sign_in
= link_to "Connexion", '/users/sign_in', :class => 'btn btn-lg'
#sign_in.col-xs-2
= link_to "Connexion", new_user_session_path, :class => 'btn btn-lg btn-primary'

View file

@ -1,4 +1,4 @@
%div.col-lg-8.col-md-8.col-sm-8.col-xs-8.main-info
.col-xs-7.main-info
%span{ 'data-toggle' => :tooltip, "data-placement" => :bottom, title: @facade.dossier.procedure.libelle }
= @facade.dossier.procedure.libelle.truncate(60)
%div.col-lg-3.col-md-3.col-sm-3.col-xs-3.options

View file

@ -1 +0,0 @@
<%= @dossier.procedure.mail_validated.body_for_dossier(@dossier).html_safe %>

View file

@ -1,18 +1,20 @@
#landing.max-size
#title
.center
= image_tag 'logos/logo-tps.png', id: 'logo-tps'
%h1.center
%img#logo-tps{src: image_url('logos/logo-tps.png')}
%h2.center
TéléProcédure Simplifiée
%h3.center
Plateforme publique pour réaliser des démarches administratives 100% en ligne.
.row
.col-md-8.col-md-push-2.center
%h3
Dématérialisez n'importe quelle démarche administrative en quelques minutes,
avec un outil
%strong
gratuit, simple, collaboratif et sûr
%br
%br
.center
%button.background-tps.js-scrollTo.btn.btn-lg{cible: '.demo_account'}
Envie d'essayer ?
%p.mt-1 Vous êtes intéressés ?
%p= link_to 'Programmer une démo', "mailto:#{t('dynamics.contact_email')}?subject=Demande de démo TPS", target: '_blank', class: 'btn btn-danger btn-lg'
#landing_body.max-size
.row#etapes.center

View file

@ -87,7 +87,6 @@ set :shared_paths, [
'config/france_connect.yml',
'config/initializers/mailjet.rb',
'config/initializers/storage_url.rb',
'app/views/root/landing.html.haml',
'app/views/layouts/_google_analytics.html',
'app/views/cgu/index.html.haml'
]

View file

@ -12,8 +12,6 @@ fr:
initiated: "Nouveau"
replied: "En construction"
updated: "En construction"
validated: "Figé"
submitted: "Déposé / À réceptionner"
received: "En instruction"
closed: "Accepté"
refused: "Refusé"

View file

@ -71,7 +71,6 @@ Rails.application.routes.draw do
get '/recapitulatif' => 'recapitulatif#show'
post '/recapitulatif/initiate' => 'recapitulatif#initiate'
post '/recapitulatif/submit' => 'recapitulatif#submit'
post '/commentaire' => 'commentaires#create'
resources :commentaires, only: [:index]
@ -159,7 +158,6 @@ Rails.application.routes.draw do
resource :private_formulaire
resources :dossiers do
post 'valid' => 'dossiers#valid'
post 'receive' => 'dossiers#receive'
post 'refuse' => 'dossiers#refuse'
post 'without_continuation' => 'dossiers#without_continuation'
@ -168,12 +166,11 @@ Rails.application.routes.draw do
post 'archive'
post 'unarchive'
end
post 'reopen' => 'dossiers#reopen'
put 'follow' => 'dossiers#follow'
resources :commentaires, only: [:index]
end
namespace :dossiers do
post 'filter'

View file

@ -1,9 +0,0 @@
class InitMailValidatedForAllProcedure < ActiveRecord::Migration[5.0]
def change
Procedure.all.each do |p|
unless p.mail_validated
p.mail_templates << MailValidated.create
end
end
end
end

View file

@ -0,0 +1,5 @@
class RemoveUselessDossierStates < ActiveRecord::Migration[5.0]
def change
Dossier.where(state: [:validated, :submitted]).update_all(state: :initiated)
end
end

View file

@ -0,0 +1,5 @@
class DeleteAllMailValidatedInDb < ActiveRecord::Migration[5.0]
def change
MailTemplate.where(type: "MailValidated").delete_all
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170215142944) do
ActiveRecord::Schema.define(version: 20170223170808) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

View file

@ -207,34 +207,9 @@ describe Backoffice::DossiersController, type: :controller do
end
end
describe 'POST #valid' do
before do
dossier.initiated!
sign_in gestionnaire
end
subject { post :valid, params: {dossier_id: dossier_id} }
it 'change state to validated' do
subject
dossier.reload
expect(dossier.state).to eq('validated')
end
it 'Notification email is send' do
expect(NotificationMailer).to receive(:dossier_validated).and_return(NotificationMailer)
expect(NotificationMailer).to receive(:deliver_now!)
subject
end
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) }
end
describe 'POST #receive' do
before do
dossier.submitted!
dossier.initiated!
sign_in gestionnaire
end
@ -376,6 +351,23 @@ describe Backoffice::DossiersController, type: :controller do
end
end
describe 'POST #reopen' do
before do
dossier.received!
sign_in gestionnaire
end
subject { post :reopen, params: {dossier_id: dossier_id} }
it 'change state to initiated' do
subject
dossier.reload
expect(dossier.state).to eq('initiated')
end
it { is_expected.to redirect_to backoffice_dossiers_path }
end
describe 'POST #archive' do
before do

View file

@ -4,7 +4,7 @@ shared_examples 'carte_controller_spec' do
context 'when dossiers procedure have api carto actived' do
context 'when dossier does not have a valid state' do
before do
dossier.state = 'validated'
dossier.state = 'received'
dossier.save
get :show, params: {dossier_id: dossier.id}

View file

@ -37,7 +37,7 @@ shared_examples 'description_controller_spec' do
describe 'before_action authorized_routes?' do
context 'when dossier does not have a valid state' do
before do
dossier.state = 'validated'
dossier.state = 'received'
dossier.save
get :show, params: {dossier_id: dossier.id}

View file

@ -39,7 +39,7 @@ describe Users::DossiersController, type: :controller do
describe 'before_action authorized_routes?' do
context 'when dossier does not have a valid state' do
before do
dossier.state = 'validated'
dossier.state = 'received'
dossier.save
get :show, params: {id: dossier.id}
@ -485,19 +485,6 @@ describe Users::DossiersController, type: :controller do
end
end
describe 'GET #valides' do
context 'when user is connected' do
before do
sign_in user
end
it 'returns http success' do
get :index, params: {liste: :valides}
expect(response).to have_http_status(200)
end
end
end
describe 'GET #en_instruction' do
context 'when user is connected' do
before do

View file

@ -52,40 +52,4 @@ describe Users::RecapitulatifController, type: :controller do
end
end
end
describe 'POST #submit' do
context 'when an user depose his dossier' do
let(:deposit_datetime) { Time.local(2016, 8, 1, 10, 5, 0) }
before do
dossier.validated!
Timecop.freeze(deposit_datetime) { post :submit, params: {dossier_id: dossier.id} }
dossier.reload
end
it 'dossier change his state for submitted' do
expect(dossier.state).to eq('submitted')
end
it 'dossier deposit datetime is filled' do
expect(dossier.deposit_datetime).to eq deposit_datetime
end
it 'a message informe user what his dossier is initiated' do
expect(flash[:notice]).to include('Dossier déposé avec succès.')
end
it 'Notification email is send' do
expect(NotificationMailer).to receive(:dossier_submitted).and_return(NotificationMailer)
expect(NotificationMailer).to receive(:deliver_now!)
dossier.validated!
post :submit, params: {dossier_id: dossier.id}
end
it 'Internal notification is created' do
expect(Notification.where(dossier_id: dossier.id, type_notif: 'submitted').first).not_to be_nil
end
end
end
end

View file

@ -37,16 +37,6 @@ describe DossierDecorator do
expect(subject).to eq('En construction')
end
it 'validated is valide' do
dossier.validated!
expect(subject).to eq('Figé')
end
it 'submitted is dépose' do
dossier.submitted!
expect(subject).to eq('Déposé / À réceptionner')
end
it 'closed is traité' do
dossier.closed!
expect(subject).to eq('Accepté')

View file

@ -7,10 +7,6 @@ describe MailTemplateDecorator do
context '#name' do
subject { decorator.name }
context 'when mail_template is a MailValidated' do
it { is_expected.to eq "E-mail de validation" }
end
context 'when mail_template is a MailReceived' do
let(:mail_template) {create :mail_template, :dossier_received}
it { is_expected.to eq "E-mail d'accusé de réception" }

View file

@ -5,10 +5,7 @@ describe AdminProceduresShowFacades do
let!(:dossier_0) { create(:dossier, procedure: procedure, state: 'draft') }
let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'initiated') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'validated') }
let!(:dossier_3) { create(:dossier, procedure: procedure, state: 'validated') }
let!(:dossier_4) { create(:dossier, procedure: procedure, archived: true, state: 'validated') }
let!(:dossier_5) { create(:dossier, procedure: procedure, archived: true, state: 'validated') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'replied') }
let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'initiated') }
let!(:dossier_7) { create(:dossier, procedure: procedure, state: 'updated') }
@ -23,37 +20,34 @@ describe AdminProceduresShowFacades do
describe '.dossiers' do
subject { super().dossiers }
it { expect(subject.size).to eq(7) }
it { expect(subject.size).to eq(4) }
end
describe '.dossiers_for_pie_highchart' do
subject { super().dossiers_for_pie_highchart }
it { expect(subject).to eq({'Nouveau' => 1, 'Figé' => 2, "En construction"=>1}) }
it { expect(subject).to eq({'Nouveau' => 1, "En construction"=>1}) }
end
describe '.dossiers_archived_by_state_total' do
subject { super().dossiers_archived_by_state_total }
it { expect(subject.size).to eq(2) }
it { expect(subject.size).to eq(1) }
it { expect(subject.first.state).to eq('initiated') }
it { expect(subject.first.total).to eq(1) }
it { expect(subject.last.state).to eq('validated') }
it { expect(subject.last.total).to eq(2) }
end
describe 'dossiers_archived_total' do
subject { super().dossiers_archived_total }
it { is_expected.to eq(3) }
it { is_expected.to eq(1) }
end
describe 'dossiers_total' do
subject { super().dossiers_total }
it { is_expected.to eq(7) }
it { is_expected.to eq(4) }
end
describe 'dossiers_waiting_gestionnaire_total' do
@ -65,7 +59,7 @@ describe AdminProceduresShowFacades do
describe 'dossiers_waiting_user_total' do
subject { super().dossiers_waiting_user_total }
it { is_expected.to eq(2) }
it { is_expected.to eq(1) }
end
describe 'dossiers_termine_total' do

View file

@ -10,10 +10,10 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
30.times do
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'validated')
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'initiated')
end
22.times do
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'validated')
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'received')
end
login_as gestionnaire, scope: :gestionnaire
visit backoffice_path

View file

@ -17,7 +17,6 @@ feature 'As a User I want to edit a dossier I own' do
expect(page.find('#a_traiter')['class'] ).to eq('active procedure_list_element')
page.find_by_id('brouillon').click
page.find_by_id('a_traiter').click
page.find_by_id('valides').click
page.find_by_id('en_instruction').click
page.find_by_id('termine').click
page.find_by_id('invite').click

View file

@ -9,8 +9,6 @@ feature 'on click on tabs button' do
create(:dossier, :with_entreprise, user: user, state: 'initiated')
create(:dossier, :with_entreprise, user: user, state: 'replied')
create(:dossier, :with_entreprise, user: user, state: 'updated')
create(:dossier, :with_entreprise, user: user, state: 'validated')
create(:dossier, :with_entreprise, user: user, state: 'submitted')
create(:dossier, :with_entreprise, user: user, state: 'received')
create(:dossier, :with_entreprise, user: user, state: 'closed')
create(:dossier, :with_entreprise, user: user, state: 'refused')
@ -33,21 +31,10 @@ feature 'on click on tabs button' do
end
end
context 'when he click on tabs a deposes' do
before do
visit users_dossiers_url(liste: :valides)
page.click_on 'À déposer 1'
end
scenario 'it redirect to users dossier deposes' 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 examen 2'
page.click_on 'En examen 1'
end
scenario 'it redirect to users dossier termine' do

View file

@ -12,19 +12,6 @@ RSpec.describe NotificationMailer, type: :mailer do
it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS N°#{dossier.id}") }
end
describe ".dossier_validated" do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, user: user) }
subject(:subject) { described_class.dossier_validated(dossier) }
before { dossier.reload }
it { expect(subject.body).to match("Votre dossier N°#{dossier.id} est prêt à être déposé pour instruction.") }
it { expect(subject.body).to include("Afin de finaliser son dépôt, merci de vous rendre sur", users_dossier_recapitulatif_url(dossier_id: dossier.id)) }
it { expect(subject.subject).to eq("[TPS] Votre dossier TPS N°#{dossier.id} a été validé") }
end
describe ".dossier_submitted" do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, user: user) }

View file

@ -4,8 +4,4 @@ class NotificationMailerPreview < ActionMailer::Preview
NotificationMailer.dossier_received(Dossier.last)
end
def dossier_validated
NotificationMailer.dossier_validated(Dossier.last)
end
end

View file

@ -224,12 +224,6 @@ describe Dossier do
it { is_expected.to eq 'updated' }
end
context 'when is validated the dossier' do
let(:action) { 'valid' }
it { is_expected.to eq('validated') }
end
end
end
@ -269,11 +263,6 @@ describe Dossier do
it { is_expected.to eq 'replied' }
end
context 'when is validated the dossier' do
let(:action) { 'valid' }
it { is_expected.to eq('validated') }
end
end
end
@ -307,74 +296,6 @@ describe Dossier do
it { is_expected.to eq('replied') }
end
context 'when is validated the dossier' do
let(:action) { 'valid' }
it { is_expected.to eq('validated') }
end
end
end
context 'when dossier is at state validated' do
before do
dossier.validated!
end
context 'when user is connect' do
let(:role) { 'user' }
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('validated') }
end
context 'when is submitted the dossier' do
let(:action) { 'submit' }
it { is_expected.to eq('submitted') }
end
end
context 'when gestionnaire is connect' do
let(:role) { 'gestionnaire' }
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('validated') }
end
end
end
context 'when dossier is at state submitted' do
before do
dossier.submitted!
end
context 'when user is connected' do
let(:role) { 'user' }
context 'when he posts a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('submitted') }
end
end
context 'when gestionnaire is connect' do
let(:role) { 'gestionnaire' }
context 'when he posts a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('submitted') }
end
context 'when he receive the dossier' do
let(:action) { 'receive' }
it { is_expected.to eq('received') }
end
end
end
@ -505,14 +426,11 @@ describe Dossier do
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
@ -543,12 +461,6 @@ describe Dossier do
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 }

View file

@ -39,7 +39,7 @@ describe MailTemplate do
end
end
xdescribe '.replace_tags' do
describe '.replace_tags' do
let(:dossier) { create :dossier }
let(:procedure) { dossier.procedure }
let(:mail_received) { procedure.mail_received }

View file

@ -52,7 +52,6 @@ describe Procedure do
it { expect(subject.mail_templates.size).to eq 2 }
it { expect(subject.mail_received).not_to be_nil }
it { expect(subject.mail_validated).not_to be_nil }
end
end

View file

@ -33,16 +33,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_falsey }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_falsey }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_falsey }
end
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_falsey }
@ -74,16 +64,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_falsey }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_falsey }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_falsey }
end
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_falsey }
@ -113,16 +93,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_falsey }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_falsey }
end
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_falsey }
@ -153,16 +123,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_falsey }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_falsey }
end
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_falsey }
@ -192,16 +152,6 @@ describe UserRoutesAuthorizationService do
it { is_expected.to be_truthy }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_truthy }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_truthy }
end
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_truthy }

View file

@ -9,8 +9,6 @@ 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 }
@ -25,8 +23,6 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
before do
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')
@ -83,7 +79,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
it { is_expected.to have_content('Nouveaux dossiers 1 dossier') }
it { is_expected.to have_content('Dossiers suivis 0 dossiers') }
it { is_expected.to have_content('Tous les dossiers 9 dossiers') }
it { is_expected.to have_content('Tous les dossiers 7 dossiers') }
it { is_expected.to have_content('État') }
it { is_expected.to have_content('Libellé procédure') }
@ -92,8 +88,6 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
it { is_expected.to have_content('plap') }
it { is_expected.to have_content('plep') }
it { is_expected.to have_content('plip') }
it { is_expected.to have_content('plop') }
it { is_expected.to have_content('plup') }
it { is_expected.to have_content('plyp') }
end

View file

@ -24,6 +24,11 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
end
context 'button dossier state changements' do
shared_examples 'button Accuser réception is present' do
it { expect(rendered).to have_link('Accuser réception') }
end
context 'when dossier have state initiated' do
let(:state) { 'initiated' }
@ -33,10 +38,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_content('Nouveau') }
it 'button Déclarer complet is present' do
expect(rendered).to have_css('.action')
expect(rendered).to have_content('DÉCLARER COMPLET')
end
include_examples 'button Accuser réception is present'
end
context 'when dossier have state replied' do
@ -48,10 +50,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_content('En construction') }
it 'button Déclarer complet is present' do
expect(rendered).to have_css('.action')
expect(rendered).to have_content('DÉCLARER COMPLET')
end
include_examples 'button Accuser réception is present'
end
context 'when dossier have state update' do
@ -63,44 +62,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_content('En construction') }
it 'button Déclarer complet is present' do
expect(rendered).to have_css('.action')
expect(rendered).to have_content('DÉCLARER COMPLET')
end
end
context 'when dossier have state validated' do
let(:state) { 'validated' }
before do
render
end
it { expect(rendered).to have_content('Figé') }
it 'button Déclarer complet is not present' do
expect(rendered).not_to have_css('.action')
expect(rendered).not_to have_content('Déclarer complet')
end
end
context 'when dossier have state submitted' do
let(:state) { 'submitted' }
before do
render
end
it { expect(rendered).to have_content('Déposé / À réceptionner') }
it 'button Accuser réception is present' do
expect(rendered).to have_css('.action')
expect(rendered).to have_content('ACCUSER RÉCEPTION')
end
it 'button Déclarer complet is not present' do
expect(rendered).not_to have_content('Accepter le dossier')
end
include_examples 'button Accuser réception is present'
end
context 'when dossier have state received' do

View file

@ -1,67 +0,0 @@
require 'spec_helper'
describe 'layouts/left_panels/_left_panel_users_dossierscontroller_index.html.haml', type: :view do
shared_examples 'active_tab' do
let(:user) { create :user }
before do
sign_in user
create :dossier, user: user
assign :dossiers_list_facade, (DossiersListFacades.new user, param_list)
render
end
subject { rendered }
let(:active_class) { 'div.procedure_list_element.active '+active_klass }
let(:param_list) { liste }
it { is_expected.to have_selector(active_class) }
end
describe 'list brouillon' do
let(:active_klass) { '.progress-bar-default' }
let(:liste) { 'brouillon' }
it_behaves_like 'active_tab'
end
describe 'list en construction' do
let(:active_klass) { '.progress-bar-danger' }
let(:liste) { 'a_traiter' }
it_behaves_like 'active_tab'
end
describe 'list a depose' do
let(:active_klass) { '.progress-bar-purple' }
let(:liste) { 'valides' }
it_behaves_like 'active_tab'
end
describe 'list en examen' do
let(:active_klass) { '.progress-bar-default' }
let(:liste) { 'en_instruction' }
it_behaves_like 'active_tab'
end
describe 'list cloture' do
let(:active_klass) { '.progress-bar-success' }
let(:liste) { 'termine' }
it_behaves_like 'active_tab'
end
describe 'list invite' do
let(:active_klass) { '.progress-bar-warning' }
let(:liste) { 'invite' }
it_behaves_like 'active_tab'
end
end

View file

@ -40,43 +40,6 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
it { expect(rendered).to have_content('En construction') }
end
context 'when dossier state is validated' do
let(:state) { 'validated' }
before do
render
end
it 'button Procéder au dépôt définitif est present' do
expect(rendered).to have_css('#validate_button')
expect(rendered).to have_content('Procéder au dépôt définitif')
end
it 'button Editer mon dossier n\'est plus present' do
expect(rendered).not_to have_css('#maj_infos')
expect(rendered).not_to have_content('Modifier mon dossier')
end
it 'button Modifier les document n\'est plus present' do
expect(rendered).not_to have_content('Modifier les documents')
end
end
context 'when dossier state is submitted' do
let(:state) { 'submitted' }
before do
render
end
it { expect(rendered).to have_content('Déposé / À réceptionner') }
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 closed' do
let(:state) { 'closed' }

View file

@ -6,8 +6,6 @@ describe 'users/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, user: user, state: 'initiated').decorate }
let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, user: user, state: 'replied').decorate }
let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, user: user, state: 'updated').decorate }
let!(:decorate_dossier_validated) { create(:dossier, :with_entreprise, user: user, state: 'validated').decorate }
let!(:decorate_dossier_submitted) { create(:dossier, :with_entreprise, user: user, state: 'submitted').decorate }
let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, user: user, state: 'received').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate }
let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, user: user, state: 'refused').decorate }
@ -61,27 +59,13 @@ describe 'users/dossiers/index.html.haml', type: :view do
end
end
describe 'on tab etude a deposer' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-purple' }
let(:dossiers_to_display) { user.dossiers.valides }
let(:liste) { 'valides' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_validated }
end
end
describe 'on tab etude en examen' do
let(:total_dossiers) { 2 }
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-default' }
let(:dossiers_to_display) { user.dossiers.en_instruction }
let(:liste) { 'en_instruction' }
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_submitted }
end
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_received }
end

View file

@ -107,18 +107,6 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
expect(rendered).not_to have_content('Archiver')
end
end
context 'when dossier is validated' do
let(:state) { 'validated' }
before do
render
end
it 'submitted link is not present' do
expect(rendered).not_to have_content('Procéder au dépôt définitif')
end
end
end
context 'invite is by User' do
@ -148,18 +136,6 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
expect(rendered).not_to have_content('Archiver')
end
end
context 'when dossier is validated' do
let(:state) { 'validated' }
before do
render
end
it 'submitted link is not present' do
expect(rendered).not_to have_content('Procéder au dépôt définitif')
end
end
end
end
end