Merge branch 'develop' into staging
This commit is contained in:
commit
9fbea39eca
23 changed files with 221 additions and 63 deletions
|
@ -46,6 +46,7 @@
|
||||||
min-height: 58px;
|
min-height: 58px;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.options {
|
.options {
|
||||||
|
|
|
@ -17,20 +17,21 @@ class Users::DescriptionController < UsersController
|
||||||
acc
|
acc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless @dossier.can_be_initiated?
|
||||||
|
flash[:alert] = t('errors.messages.procedure_archived')
|
||||||
|
end
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash.alert = t('errors.messages.dossier_not_found')
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
redirect_to url_for(root_path)
|
redirect_to url_for(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# def error
|
def update
|
||||||
# show
|
|
||||||
# flash.now.alert = 'Un ou plusieurs attributs obligatoires sont manquants ou incorrects.'
|
|
||||||
# render 'show'
|
|
||||||
# end
|
|
||||||
|
|
||||||
def create
|
|
||||||
@dossier = current_user_dossier
|
@dossier = current_user_dossier
|
||||||
@procedure = @dossier.procedure
|
@procedure = @dossier.procedure
|
||||||
|
|
||||||
|
return head :forbidden unless @dossier.can_be_initiated?
|
||||||
|
|
||||||
@champs = @dossier.ordered_champs
|
@champs = @dossier.ordered_champs
|
||||||
|
|
||||||
mandatory = true
|
mandatory = true
|
||||||
|
|
|
@ -13,8 +13,11 @@ class AdminProceduresShowFacades
|
||||||
|
|
||||||
def dossiers_for_pie_highchart
|
def dossiers_for_pie_highchart
|
||||||
dossiers.where.not(state: :draft, archived: true).group(:state).count
|
dossiers.where.not(state: :draft, archived: true).group(:state).count
|
||||||
.map{|key, value| { (DossierDecorator.case_state_fr key) => value } }
|
.reduce({}) do |acc, (key, val)|
|
||||||
.reduce({}, :merge)
|
translated_key = DossierDecorator.case_state_fr(key)
|
||||||
|
acc[translated_key].nil? ? acc[translated_key] = val : acc[translated_key] += val
|
||||||
|
acc
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossiers_archived_by_state_total
|
def dossiers_archived_by_state_total
|
||||||
|
|
|
@ -38,6 +38,8 @@ class Dossier < ActiveRecord::Base
|
||||||
delegate :types_de_champ, to: :procedure
|
delegate :types_de_champ, to: :procedure
|
||||||
delegate :france_connect_information, to: :user
|
delegate :france_connect_information, to: :user
|
||||||
|
|
||||||
|
before_validation :update_state_dates, if: -> { state_changed? }
|
||||||
|
|
||||||
after_save :build_default_champs, if: Proc.new { procedure_id_changed? }
|
after_save :build_default_champs, if: Proc.new { procedure_id_changed? }
|
||||||
after_save :build_default_individual, if: Proc.new { procedure.for_individual? }
|
after_save :build_default_individual, if: Proc.new { procedure.for_individual? }
|
||||||
|
|
||||||
|
@ -304,4 +306,21 @@ class Dossier < ActiveRecord::Base
|
||||||
def invite_by_user? email
|
def invite_by_user? email
|
||||||
(invites_user.pluck :email).include? email
|
(invites_user.pluck :email).include? email
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_be_initiated?
|
||||||
|
!(procedure.archived && draft?)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def update_state_dates
|
||||||
|
if initiated? && !self.initiated_at
|
||||||
|
self.initiated_at = DateTime.now
|
||||||
|
elsif received? && !self.received_at
|
||||||
|
self.received_at = DateTime.now
|
||||||
|
elsif TERMINE.include?(state)
|
||||||
|
self.processed_at = DateTime.now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,10 @@ class DossierProcedureSerializer < ActiveModel::Serializer
|
||||||
:updated_at,
|
:updated_at,
|
||||||
:archived,
|
:archived,
|
||||||
:mandataire_social,
|
:mandataire_social,
|
||||||
:state
|
:state,
|
||||||
|
:initiated_at,
|
||||||
|
:received_at,
|
||||||
|
:processed_at
|
||||||
|
|
||||||
attribute :followers_gestionnaires_emails, key: :emails_accompagnateurs
|
attribute :followers_gestionnaires_emails, key: :emails_accompagnateurs
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,15 +15,13 @@
|
||||||
= smart_listing_render :new_dossiers
|
= smart_listing_render :new_dossiers
|
||||||
|
|
||||||
.row.center
|
.row.center
|
||||||
.col-xs-2.col-xs-offset-1
|
.col-xs-3
|
||||||
=link_to 'Tous les états', '?liste=all_state', class: 'text-info', style:"text-decoration: #{@facade_data_view.liste == 'all_state'? 'underline' : ''}"
|
=link_to 'Tous les états', '?liste=all_state', class: 'text-info', style:"text-decoration: #{@facade_data_view.liste == 'all_state'? 'underline' : ''}"
|
||||||
.col-xs-2
|
.col-xs-3
|
||||||
=link_to 'En construction', '?liste=a_traiter', class: 'text-danger', style:"text-decoration: #{@facade_data_view.liste == 'a_traiter'? 'underline' : ''}"
|
=link_to 'En construction', '?liste=a_traiter', class: 'text-danger', style:"text-decoration: #{@facade_data_view.liste == 'a_traiter'? 'underline' : ''}"
|
||||||
.col-xs-2
|
.col-xs-3
|
||||||
=link_to 'À receptionner', '?liste=deposes', class: 'text-purple', style:"text-decoration: #{@facade_data_view.liste == 'deposes'? 'underline' : ''}"
|
=link_to 'En instruction', '?liste=a_instruire', class: 'text-warning', style:"text-decoration: #{@facade_data_view.liste == 'a_instruire'? 'underline' : ''}"
|
||||||
.col-xs-2
|
.col-xs-3
|
||||||
=link_to 'À instruire', '?liste=a_instruire', class: 'text-warning', style:"text-decoration: #{@facade_data_view.liste == 'a_instruire'? 'underline' : ''}"
|
|
||||||
.col-xs-2
|
|
||||||
=link_to 'Terminés', '?liste=termine', class: 'text-success', style:"text-decoration: #{@facade_data_view.liste == 'termine'? 'underline' : ''}"
|
=link_to 'Terminés', '?liste=termine', class: 'text-success', style:"text-decoration: #{@facade_data_view.liste == 'termine'? 'underline' : ''}"
|
||||||
|
|
||||||
.default_data_block.default_visible
|
.default_data_block.default_visible
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#action-block
|
#action-block
|
||||||
- if gestionnaire_signed_in?
|
- if gestionnaire_signed_in?
|
||||||
- if !@facade.dossier.read_only? || @facade.dossier.initiated?
|
- 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'
|
= link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block'
|
||||||
|
|
||||||
- elsif @facade.dossier.received?
|
- 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
|
= 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
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
|
|
||||||
%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.'}
|
%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' }
|
%div.procedure_list_element{ class: @dossiers_list_facade.en_instruction_class, id: 'en_instruction' }
|
||||||
="En examen"
|
="En instruction"
|
||||||
.badge.progress-bar-default
|
.badge.progress-bar-default
|
||||||
= @dossiers_list_facade.en_instruction_total
|
= @dossiers_list_facade.en_instruction_total
|
||||||
|
|
||||||
%a{:href => "#{url_for users_dossiers_path(liste: 'termine')}", 'data-toggle' => :tooltip, title: 'Les dossiers cloturés qui peuvent être "Accepté", "Refusé" ou "Sans suite".'}
|
%a{:href => "#{url_for users_dossiers_path(liste: 'termine')}", 'data-toggle' => :tooltip, title: 'Les dossiers cloturés qui peuvent être "Accepté", "Refusé" ou "Sans suite".'}
|
||||||
%div.procedure_list_element{ class: @dossiers_list_facade.termine_class, id: 'termine' }
|
%div.procedure_list_element{ class: @dossiers_list_facade.termine_class, id: 'termine' }
|
||||||
= "Cloturé"
|
= "Terminé"
|
||||||
.badge.progress-bar-success
|
.badge.progress-bar-success
|
||||||
= @dossiers_list_facade.termine_total
|
= @dossiers_list_facade.termine_total
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
= @dossier.procedure.libelle
|
= @dossier.procedure.libelle
|
||||||
|
|
||||||
-#TODO use form_for
|
-#TODO use form_for
|
||||||
= form_tag(url_for({controller: 'users/description', action: :create, dossier_id: @dossier.id}), class: 'form', method: 'POST', multipart: true) do
|
= form_tag(url_for({controller: 'users/description', action: :update, dossier_id: @dossier.id}), class: 'form', method: 'POST', multipart: true) do
|
||||||
-unless @champs.nil?
|
-unless @champs.nil?
|
||||||
#liste_champs
|
#liste_champs
|
||||||
=render partial: 'users/description/champs', locals:{private: false}
|
=render partial: 'users/description/champs', locals:{private: false}
|
||||||
|
@ -41,16 +41,16 @@
|
||||||
Vous pourrez dans tous les cas les compléter plus tard si vous ne les possédez pas de suite.
|
Vous pourrez dans tous les cas les compléter plus tard si vous ne les possédez pas de suite.
|
||||||
|
|
||||||
|
|
||||||
-route = Rails.application.routes.recognize_path(request.referrer)
|
-route = Rails.application.routes.recognize_path(request.referrer) # WTF ?
|
||||||
- unless route[:controller].match('admin')
|
- unless route[:controller].match('admin')
|
||||||
%div{style: 'text-align:right'}
|
%div{style: 'text-align:right'}
|
||||||
%h6 Tous les champs portant un * sont obligatoires.
|
%h6 Tous les champs portant un * sont obligatoires.
|
||||||
|
|
||||||
-if !@dossier.draft?
|
- if !@dossier.can_be_initiated?
|
||||||
=render partial: '/layouts/modifications_terminees'
|
.alert.alert-danger
|
||||||
-else
|
= t('errors.messages.procedure_archived')
|
||||||
= submit_tag 'Soumettre mon dossier', id: 'suivant', name: 'submit[nouveaux]', class: %w(btn btn btn-success), style: 'float:right', data: { disable_with: 'Soumettre votre dossier', submit: true}
|
- elsif !@dossier.draft?
|
||||||
= submit_tag 'Enregistrer un brouillon', id: 'brouillon', name: 'submit[brouillon]', class: %w(btn btn-xs btn-default), style: 'float:right; margin-right: 10px; margin-top: 6px', data: {disable_with: 'Enregistrer un brouillon', submit: true}
|
= render partial: '/layouts/modifications_terminees'
|
||||||
|
- else
|
||||||
%br
|
= submit_tag 'Soumettre mon dossier', id: 'suivant', name: 'submit[nouveaux]', class: 'btn btn btn-success', style: 'float:right', disabled: @procedure.archived?, data: { disable_with: 'Soumettre votre dossier', submit: true}
|
||||||
%br
|
= submit_tag 'Enregistrer un brouillon', id: 'brouillon', name: 'submit[brouillon]', class: 'btn btn-xs btn-default', style: 'float:right; margin-right: 10px; margin-top: 6px', disabled: @procedure.archived?, data: {disable_with: 'Enregistrer un brouillon', submit: true}
|
||||||
|
|
|
@ -147,6 +147,7 @@ fr:
|
||||||
france_connect:
|
france_connect:
|
||||||
connexion: "Erreur lors de la connexion à France Connect."
|
connexion: "Erreur lors de la connexion à France Connect."
|
||||||
extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide."
|
extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide."
|
||||||
|
procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier."
|
||||||
|
|
||||||
datetime:
|
datetime:
|
||||||
distance_in_words:
|
distance_in_words:
|
||||||
|
|
|
@ -9,7 +9,7 @@ fr:
|
||||||
date_previsionnelle: "La date de début prévisionnelle"
|
date_previsionnelle: "La date de début prévisionnelle"
|
||||||
state:
|
state:
|
||||||
draft: "Brouillon"
|
draft: "Brouillon"
|
||||||
initiated: "Nouveau"
|
initiated: "En construction"
|
||||||
replied: "En construction"
|
replied: "En construction"
|
||||||
updated: "En construction"
|
updated: "En construction"
|
||||||
received: "En instruction"
|
received: "En instruction"
|
||||||
|
|
|
@ -63,9 +63,8 @@ Rails.application.routes.draw do
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
get '/add_siret' => 'dossiers/add_siret#show'
|
get '/add_siret' => 'dossiers/add_siret#show'
|
||||||
|
|
||||||
get '/description' => 'description#show'
|
get 'description' => 'description#show'
|
||||||
# get '/description/error' => 'description#error'
|
post 'description' => 'description#update'
|
||||||
post 'description' => 'description#create'
|
|
||||||
|
|
||||||
patch 'pieces_justificatives' => 'description#pieces_justificatives'
|
patch 'pieces_justificatives' => 'description#pieces_justificatives'
|
||||||
|
|
||||||
|
|
7
db/migrate/20170228144909_add_state_dates_to_dossiers.rb
Normal file
7
db/migrate/20170228144909_add_state_dates_to_dossiers.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class AddStateDatesToDossiers < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
add_column :dossiers, :initiated_at, :datetime
|
||||||
|
add_column :dossiers, :received_at, :datetime
|
||||||
|
add_column :dossiers, :processed_at, :datetime
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
class RemoveDepositDatetimeFromDossiers < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
Dossier.where.not(deposit_datetime: nil).each do |dossier|
|
||||||
|
dossier.update(initiated_at: dossier.deposit_datetime)
|
||||||
|
end
|
||||||
|
remove_column :dossiers, :deposit_datetime, :datetime
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170228150522) do
|
ActiveRecord::Schema.define(version: 20170302112312) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -126,7 +126,9 @@ ActiveRecord::Schema.define(version: 20170228150522) do
|
||||||
t.text "json_latlngs"
|
t.text "json_latlngs"
|
||||||
t.boolean "archived", default: false
|
t.boolean "archived", default: false
|
||||||
t.boolean "mandataire_social", default: false
|
t.boolean "mandataire_social", default: false
|
||||||
t.datetime "deposit_datetime"
|
t.datetime "initiated_at"
|
||||||
|
t.datetime "received_at"
|
||||||
|
t.datetime "processed_at"
|
||||||
t.index ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
t.index ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
||||||
t.index ["user_id"], name: "index_dossiers_on_user_id", using: :btree
|
t.index ["user_id"], name: "index_dossiers_on_user_id", using: :btree
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,12 +17,27 @@ shared_examples 'description_controller_spec' do
|
||||||
context 'when all is ok' do
|
context 'when all is ok' do
|
||||||
before do
|
before do
|
||||||
dossier.entreprise = create :entreprise
|
dossier.entreprise = create :entreprise
|
||||||
|
get :show, params: {dossier_id: dossier_id}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :show, params: {dossier_id: dossier_id}
|
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'procedure is archived' do
|
||||||
|
render_views
|
||||||
|
let(:archived) { true }
|
||||||
|
|
||||||
|
it { expect(response).to have_http_status(:success) }
|
||||||
|
it { expect(response.body).to_not have_content(I18n.t('errors.messages.procedure_archived')) }
|
||||||
|
|
||||||
|
context 'dossier is a draft' do
|
||||||
|
let(:state) { 'draft' }
|
||||||
|
|
||||||
|
it { expect(response).to have_http_status(:success) }
|
||||||
|
it { expect(response.body).to have_content(I18n.t('errors.messages.procedure_archived')) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirection vers start si mauvais dossier ID' do
|
it 'redirection vers start si mauvais dossier ID' do
|
||||||
|
@ -90,7 +105,7 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #create' do
|
describe 'POST #update' do
|
||||||
let(:timestamp) { Time.now }
|
let(:timestamp) { Time.now }
|
||||||
let(:description) { 'Description de test Coucou, je suis un saut à la ligne Je suis un double saut la ligne.' }
|
let(:description) { 'Description de test Coucou, je suis un saut à la ligne Je suis un double saut la ligne.' }
|
||||||
|
|
||||||
|
@ -98,7 +113,7 @@ shared_examples 'description_controller_spec' do
|
||||||
describe 'Premier enregistrement des données' do
|
describe 'Premier enregistrement des données' do
|
||||||
let(:submit) { {nouveaux: 'nouveaux'} }
|
let(:submit) { {nouveaux: 'nouveaux'} }
|
||||||
|
|
||||||
subject { post :create, params: {dossier_id: dossier_id, submit: submit} }
|
subject { post :update, params: {dossier_id: dossier_id, submit: submit} }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
dossier.draft!
|
dossier.draft!
|
||||||
|
@ -130,7 +145,7 @@ shared_examples 'description_controller_spec' do
|
||||||
context 'En train de manipuler un dossier non brouillon' do
|
context 'En train de manipuler un dossier non brouillon' do
|
||||||
before do
|
before do
|
||||||
dossier.initiated!
|
dossier.initiated!
|
||||||
post :create, params: {dossier_id: dossier_id}
|
post :update, params: {dossier_id: dossier_id}
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,7 +160,7 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Quand la procédure accepte les CERFA' do
|
context 'Quand la procédure accepte les CERFA' do
|
||||||
subject { post :create, params: {dossier_id: dossier_id,
|
subject { post :update, params: {dossier_id: dossier_id,
|
||||||
cerfa_pdf: cerfa_pdf} }
|
cerfa_pdf: cerfa_pdf} }
|
||||||
|
|
||||||
it 'Notification interne is create' do
|
it 'Notification interne is create' do
|
||||||
|
@ -154,7 +169,7 @@ shared_examples 'description_controller_spec' do
|
||||||
|
|
||||||
context 'Sauvegarde du CERFA PDF', vcr: {cassette_name: 'controllers_users_description_controller_save_cerfa'} do
|
context 'Sauvegarde du CERFA PDF', vcr: {cassette_name: 'controllers_users_description_controller_save_cerfa'} do
|
||||||
before do
|
before do
|
||||||
post :create, params: {dossier_id: dossier_id,
|
post :update, params: {dossier_id: dossier_id,
|
||||||
cerfa_pdf: cerfa_pdf}
|
cerfa_pdf: cerfa_pdf}
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
@ -181,7 +196,7 @@ shared_examples 'description_controller_spec' do
|
||||||
let(:cerfas) { Cerfa.where(dossier_id: dossier_id) }
|
let(:cerfas) { Cerfa.where(dossier_id: dossier_id) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
post :create, params: {dossier_id: dossier_id, cerfa_pdf: cerfa_pdf}
|
post :update, params: {dossier_id: dossier_id, cerfa_pdf: cerfa_pdf}
|
||||||
end
|
end
|
||||||
|
|
||||||
it "il y a deux CERFA PDF pour ce dossier" do
|
it "il y a deux CERFA PDF pour ce dossier" do
|
||||||
|
@ -195,7 +210,7 @@ shared_examples 'description_controller_spec' do
|
||||||
context 'Sauvegarde du CERFA PDF' do
|
context 'Sauvegarde du CERFA PDF' do
|
||||||
let!(:procedure) { create(:procedure) }
|
let!(:procedure) { create(:procedure) }
|
||||||
before do
|
before do
|
||||||
post :create, params: {dossier_id: dossier_id,
|
post :update, params: {dossier_id: dossier_id,
|
||||||
cerfa_pdf: cerfa_pdf}
|
cerfa_pdf: cerfa_pdf}
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
@ -214,7 +229,7 @@ shared_examples 'description_controller_spec' do
|
||||||
let(:dossier_minute_value) { '00' }
|
let(:dossier_minute_value) { '00' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
post :create, params: {dossier_id: dossier_id,
|
post :update, params: {dossier_id: dossier_id,
|
||||||
champs: {
|
champs: {
|
||||||
"'#{dossier.champs.first.id}'" => dossier_champs_first,
|
"'#{dossier.champs.first.id}'" => dossier_champs_first,
|
||||||
"'#{dossier.champs.second.id}'" => dossier_date_value
|
"'#{dossier.champs.second.id}'" => dossier_date_value
|
||||||
|
@ -254,7 +269,7 @@ shared_examples 'description_controller_spec' do
|
||||||
context 'Sauvegarde des pièces justificatives', vcr: {cassette_name: 'controllers_users_description_controller_sauvegarde_pj'} do
|
context 'Sauvegarde des pièces justificatives', vcr: {cassette_name: 'controllers_users_description_controller_sauvegarde_pj'} do
|
||||||
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
||||||
before do
|
before do
|
||||||
post :create, params: {dossier_id: dossier_id,
|
post :update, params: {dossier_id: dossier_id,
|
||||||
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
|
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
|
||||||
'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
|
'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
|
||||||
dossier.reload
|
dossier.reload
|
||||||
|
@ -264,7 +279,7 @@ shared_examples 'description_controller_spec' do
|
||||||
it 'ClamavService safe_file? is call' do
|
it 'ClamavService safe_file? is call' do
|
||||||
expect(ClamavService).to receive(:safe_file?).twice
|
expect(ClamavService).to receive(:safe_file?).twice
|
||||||
|
|
||||||
post :create, params: {dossier_id: dossier_id,
|
post :update, params: {dossier_id: dossier_id,
|
||||||
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
|
'piece_justificative_'+all_pj_type[0].to_s => piece_justificative_0,
|
||||||
'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
|
'piece_justificative_'+all_pj_type[1].to_s => piece_justificative_1}
|
||||||
end
|
end
|
||||||
|
@ -281,6 +296,22 @@ shared_examples 'description_controller_spec' do
|
||||||
it { expect(subject.user).to eq user }
|
it { expect(subject.user).to eq user }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'La procédure est archivée' do
|
||||||
|
let(:archived) { true }
|
||||||
|
|
||||||
|
before do
|
||||||
|
post :update, params: { dossier_id: dossier.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response.status).to eq(302) }
|
||||||
|
|
||||||
|
context 'Le dossier est en brouillon' do
|
||||||
|
let(:state) { 'draft' }
|
||||||
|
|
||||||
|
it { expect(response.status).to eq(403) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #pieces_justificatives', vcr: {cassette_name: 'controllers_users_description_controller_pieces_justificatives'} do
|
describe 'POST #pieces_justificatives', vcr: {cassette_name: 'controllers_users_description_controller_pieces_justificatives'} do
|
||||||
|
|
|
@ -5,9 +5,11 @@ require 'controllers/users/description_controller_shared_example'
|
||||||
describe Users::DescriptionController, type: :controller, vcr: {cassette_name: 'controllers_users_description_controller'} do
|
describe Users::DescriptionController, type: :controller, vcr: {cassette_name: 'controllers_users_description_controller'} do
|
||||||
let(:owner_user) { create(:user) }
|
let(:owner_user) { create(:user) }
|
||||||
let(:invite_by_user) { create :user, email: 'invite@plop.com' }
|
let(:invite_by_user) { create :user, email: 'invite@plop.com' }
|
||||||
|
let(:archived) { false }
|
||||||
|
let(:state) { 'initiated' }
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true) }
|
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true, archived: archived) }
|
||||||
let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: 'initiated') }
|
let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) }
|
||||||
|
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:bad_dossier_id) { Dossier.count + 10000 }
|
let(:bad_dossier_id) { Dossier.count + 10000 }
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe DossierDecorator do
|
||||||
|
|
||||||
it 'initiated is initiate' do
|
it 'initiated is initiate' do
|
||||||
dossier.initiated!
|
dossier.initiated!
|
||||||
expect(subject).to eq('Nouveau')
|
expect(subject).to eq('En construction')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'replied is repondu' do
|
it 'replied is repondu' do
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe AdminProceduresShowFacades do
|
||||||
describe '.dossiers_for_pie_highchart' do
|
describe '.dossiers_for_pie_highchart' do
|
||||||
subject { super().dossiers_for_pie_highchart }
|
subject { super().dossiers_for_pie_highchart }
|
||||||
|
|
||||||
it { expect(subject).to eq({'Nouveau' => 1, "En construction"=>1}) }
|
it { expect(subject).to eq({ 'En construction' => 3 }) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.dossiers_archived_by_state_total' do
|
describe '.dossiers_archived_by_state_total' do
|
||||||
|
|
|
@ -34,7 +34,7 @@ feature 'on click on tabs button' do
|
||||||
context 'when he click on tabs en examen' do
|
context 'when he click on tabs en examen' do
|
||||||
before do
|
before do
|
||||||
visit users_dossiers_url(liste: :en_instruction)
|
visit users_dossiers_url(liste: :en_instruction)
|
||||||
page.click_on 'En examen 1'
|
page.click_on 'En instruction 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'it redirect to users dossier termine' do
|
scenario 'it redirect to users dossier termine' do
|
||||||
|
@ -45,7 +45,7 @@ feature 'on click on tabs button' do
|
||||||
context 'when he click on tabs termine' do
|
context 'when he click on tabs termine' do
|
||||||
before do
|
before do
|
||||||
visit users_dossiers_url(liste: :termine)
|
visit users_dossiers_url(liste: :termine)
|
||||||
page.click_on 'Cloturé 3'
|
page.click_on 'Terminé 3'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'it redirect to users dossier termine' do
|
scenario 'it redirect to users dossier termine' do
|
||||||
|
|
|
@ -597,7 +597,10 @@ describe Dossier do
|
||||||
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||||
let(:gestionnaire) { create(:gestionnaire) }
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
|
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, follows: [follow]) }
|
let(:date1) { 1.day.ago }
|
||||||
|
let(:date2) { 1.hour.ago }
|
||||||
|
let(:date3) { 1.minute.ago }
|
||||||
|
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, follows: [follow], initiated_at: date1, received_at: date2, processed_at: date3) }
|
||||||
|
|
||||||
describe '#export_headers' do
|
describe '#export_headers' do
|
||||||
|
|
||||||
|
@ -608,6 +611,7 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#data_with_champs' do
|
describe '#data_with_champs' do
|
||||||
|
|
||||||
subject { dossier.data_with_champs }
|
subject { dossier.data_with_champs }
|
||||||
|
|
||||||
it { expect(subject[0]).to be_a_kind_of(Integer) }
|
it { expect(subject[0]).to be_a_kind_of(Integer) }
|
||||||
|
@ -616,14 +620,17 @@ describe Dossier do
|
||||||
it { expect(subject[3]).to be_in([true, false]) }
|
it { expect(subject[3]).to be_in([true, false]) }
|
||||||
it { expect(subject[4]).to be_in([true, false]) }
|
it { expect(subject[4]).to be_in([true, false]) }
|
||||||
it { expect(subject[5]).to eq("draft") }
|
it { expect(subject[5]).to eq("draft") }
|
||||||
it { expect(subject[6]).to eq(dossier.followers_gestionnaires_emails) }
|
it { expect(subject[6]).to eq(date1) }
|
||||||
|
it { expect(subject[7]).to eq(date2) }
|
||||||
|
it { expect(subject[8]).to eq(date3) }
|
||||||
|
it { expect(subject[9]).to eq(dossier.followers_gestionnaires_emails) }
|
||||||
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
|
it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#Dossier.to_csv' do
|
describe '#Dossier.to_csv' do
|
||||||
let!(:procedure) { create(:procedure) }
|
let!(:procedure) { create(:procedure) }
|
||||||
let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, ) }
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
dossier_hash = {}
|
dossier_hash = {}
|
||||||
|
@ -881,6 +888,82 @@ describe Dossier do
|
||||||
it { is_expected.to eq "#{gestionnaire.email} #{gestionnaire2.email}" }
|
it { is_expected.to eq "#{gestionnaire.email} #{gestionnaire2.email}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#update_state_dates' do
|
||||||
|
let(:state) { 'draft' }
|
||||||
|
let(:dossier) { create(:dossier, state: state) }
|
||||||
|
let(:beginning_of_day) { Time.now.beginning_of_day }
|
||||||
|
|
||||||
|
before do
|
||||||
|
Timecop.freeze(beginning_of_day)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is initiated' do
|
||||||
|
before do
|
||||||
|
dossier.initiated!
|
||||||
|
dossier.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(dossier.state).to eq('initiated') }
|
||||||
|
it { expect(dossier.initiated_at).to eq(beginning_of_day) }
|
||||||
|
|
||||||
|
it 'should keep first initiated_at date' do
|
||||||
|
Timecop.return
|
||||||
|
dossier.received!
|
||||||
|
dossier.initiated!
|
||||||
|
|
||||||
|
expect(dossier.initiated_at).to eq(beginning_of_day)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is received' do
|
||||||
|
let(:state) { 'initiated' }
|
||||||
|
|
||||||
|
before do
|
||||||
|
dossier.received!
|
||||||
|
dossier.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(dossier.state).to eq('received') }
|
||||||
|
it { expect(dossier.received_at).to eq(beginning_of_day) }
|
||||||
|
|
||||||
|
it 'should keep first received_at date if dossier is set to initiated again' do
|
||||||
|
Timecop.return
|
||||||
|
dossier.initiated!
|
||||||
|
dossier.received!
|
||||||
|
|
||||||
|
expect(dossier.received_at).to eq(beginning_of_day)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples 'dossier is processed' do |new_state|
|
||||||
|
before do
|
||||||
|
dossier.update(state: new_state)
|
||||||
|
dossier.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(dossier.state).to eq(new_state) }
|
||||||
|
it { expect(dossier.processed_at).to eq(beginning_of_day) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is closed' do
|
||||||
|
let(:state) { 'received' }
|
||||||
|
|
||||||
|
it_behaves_like 'dossier is processed', 'closed'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is refused' do
|
||||||
|
let(:state) { 'received' }
|
||||||
|
|
||||||
|
it_behaves_like 'dossier is processed', 'refused'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is without_continuation' do
|
||||||
|
let(:state) { 'received' }
|
||||||
|
|
||||||
|
it_behaves_like 'dossier is processed', 'without_continuation'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,8 +25,8 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
||||||
|
|
||||||
context 'button dossier state changements' do
|
context 'button dossier state changements' do
|
||||||
|
|
||||||
shared_examples 'button Accuser réception is present' do
|
shared_examples 'button Passer en instruction is present' do
|
||||||
it { expect(rendered).to have_link('Accuser réception') }
|
it { expect(rendered).to have_link('Passer en instruction') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state initiated' do
|
context 'when dossier have state initiated' do
|
||||||
|
@ -36,9 +36,9 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Nouveau') }
|
it { expect(rendered).to have_content('En construction') }
|
||||||
|
|
||||||
include_examples 'button Accuser réception is present'
|
include_examples 'button Passer en instruction is present'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state replied' do
|
context 'when dossier have state replied' do
|
||||||
|
@ -50,7 +50,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
||||||
|
|
||||||
it { expect(rendered).to have_content('En construction') }
|
it { expect(rendered).to have_content('En construction') }
|
||||||
|
|
||||||
include_examples 'button Accuser réception is present'
|
include_examples 'button Passer en instruction is present'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state update' do
|
context 'when dossier have state update' do
|
||||||
|
@ -62,7 +62,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
||||||
|
|
||||||
it { expect(rendered).to have_content('En construction') }
|
it { expect(rendered).to have_content('En construction') }
|
||||||
|
|
||||||
include_examples 'button Accuser réception is present'
|
include_examples 'button Passer en instruction is present'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier have state received' do
|
context 'when dossier have state received' do
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(rendered).to have_content('Nouveau') }
|
it { expect(rendered).to have_content('En construction') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier state is replied' do
|
context 'when dossier state is replied' do
|
||||||
|
|
Loading…
Reference in a new issue