commit
fac9c6cf47
30 changed files with 231 additions and 332 deletions
27
README.md
27
README.md
|
@ -53,25 +53,10 @@ Afin de générer la BDD de l'application, il est nécessaire d'exécuter les co
|
|||
|
||||
## Bouchonnage de l’authentification
|
||||
|
||||
Créer le fichier `config/france_connect.yml` avec le contenu
|
||||
Créer les fichiers de configuration avec les valeurs par défaut :
|
||||
|
||||
```yaml
|
||||
particulier_identifier: ''
|
||||
particulier_secret: ''
|
||||
|
||||
particulier_redirect_uri: ''
|
||||
particulier_authorization_endpoint: ''
|
||||
particulier_token_endpoint: ''
|
||||
particulier_userinfo_endpoint: ''
|
||||
particulier_logout_endpoint: ''
|
||||
```
|
||||
|
||||
Créer le fichier `config/github_secrets.yml` avec le contenu
|
||||
|
||||
```yaml
|
||||
client_id: ''
|
||||
client_secret: ''
|
||||
```
|
||||
cp config/france_connect.example.yml config/france_connect.yml
|
||||
cp config/github_secrets.example.yml config/github_secrets.yml
|
||||
|
||||
## Connexion a Pipedrive
|
||||
|
||||
|
@ -149,6 +134,12 @@ Une fois `overmind` lancé, et un breakpoint `byebug` inséré dans le code, il
|
|||
- supprimer un compte super admin :
|
||||
`bin/rake admin:delete_admin[email-du-compte-github@exemple.com]`
|
||||
|
||||
|
||||
## Tâches d’aide au support
|
||||
|
||||
Des tâches d’aide au support sont prévues dans le namespace `support`.
|
||||
Pour les lister: `bin/rake -D support:`.
|
||||
|
||||
## Compatibilité navigateurs
|
||||
|
||||
L'application supporte les navigateurs récents Firefox, Chrome, Internet Explorer (Edge, 11).
|
||||
|
|
|
@ -16,4 +16,9 @@
|
|||
.tt-menu {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
// Fix the input not being displayed on the same line than the text before
|
||||
.tt-input {
|
||||
vertical-align: initial !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,20 @@
|
|||
.etablissement-titre {
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
||||
// Align checkboxes on the top-left side of the label
|
||||
&.editable-champ-checkbox,
|
||||
&.editable-champ-engagement {
|
||||
label {
|
||||
padding-left: 28px;
|
||||
}
|
||||
|
||||
input[type=checkbox] {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
left: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.radios {
|
||||
|
@ -112,9 +126,18 @@
|
|||
|
||||
input[type=checkbox],
|
||||
input[type=radio] {
|
||||
margin-left: 5px;
|
||||
margin-right: 4px;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
||||
input[type=checkbox] {
|
||||
// Firefox tends to display checkbox controls smaller than other browsers.
|
||||
// Ensure a consistency of size between browsers.
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
input[type=date] {
|
||||
max-width: 180px;
|
||||
}
|
||||
|
|
|
@ -29,10 +29,6 @@
|
|||
|
||||
.white-back {
|
||||
margin: 20px !important;
|
||||
|
||||
#previsualisation {
|
||||
margin-top: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.white-back,
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
class Admin::PrevisualisationsController < AdminController
|
||||
before_action :retrieve_procedure
|
||||
|
||||
def show
|
||||
@procedure
|
||||
@dossier = Dossier.new(id: 0, procedure: @procedure)
|
||||
|
||||
PrevisualisationService.delete_all_champs @dossier
|
||||
@dossier.build_default_champs
|
||||
|
||||
@champs = @dossier.ordered_champs
|
||||
|
||||
@headers = @champs.select { |champ| champ.type_champ == 'header_section' }
|
||||
end
|
||||
end
|
|
@ -101,11 +101,15 @@ module NewUser
|
|||
|
||||
def ask_deletion
|
||||
dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id])
|
||||
deleted_dossier = dossier.delete_and_keep_track
|
||||
DossierMailer.notify_deletion_to_user(deleted_dossier, dossier.user.email).deliver_later
|
||||
DossierMailer.notify_deletion_to_administration(deleted_dossier, dossier.procedure.administrateur.email).deliver_later
|
||||
flash.notice = 'Votre dossier a bien été supprimé.'
|
||||
redirect_to users_dossiers_path
|
||||
|
||||
if !dossier.instruction_commencee?
|
||||
dossier.delete_and_keep_track
|
||||
flash.notice = 'Votre dossier a bien été supprimé.'
|
||||
redirect_to users_dossiers_path
|
||||
else
|
||||
flash.notice = "L'instruction de votre dossier a commencé, il n'est plus possible de supprimer votre dossier. Si vous souhaitez annuler l'instruction contactez votre administration par la messagerie de votre dossier."
|
||||
redirect_to users_dossier_path(dossier)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module ChampHelper
|
||||
def is_not_header_nor_explication?(champ)
|
||||
!['header_section', 'explication'].include?(champ.type_champ)
|
||||
def has_label?(champ)
|
||||
types_without_label = ['header_section', 'explication']
|
||||
!types_without_label.include?(champ.type_champ)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,14 +14,4 @@ module DossierHelper
|
|||
"highlighted"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_dossier_confirm(dossier)
|
||||
message = ["Vous vous apprêtez à supprimer votre dossier ainsi que les informations qu’il contient."]
|
||||
if dossier.en_construction_ou_instruction?
|
||||
message << "Nous vous rappelons que toute suppression entraine l’annulation de la démarche en cours."
|
||||
end
|
||||
message << "Confirmer la suppression ?"
|
||||
|
||||
message.join(" ")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,4 +14,11 @@ class DossierMailer < ApplicationMailer
|
|||
|
||||
mail(to: to_email, subject: subject)
|
||||
end
|
||||
|
||||
def notify_unhide_to_user(dossier)
|
||||
@dossier = dossier
|
||||
subject = "Votre dossier n° #{@dossier.id} n'a pas pu être supprimé"
|
||||
|
||||
mail(to: dossier.user.email, subject: subject)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,6 +44,7 @@ class Dossier < ApplicationRecord
|
|||
scope :state_en_construction, -> { where(state: 'en_construction') }
|
||||
scope :state_en_instruction, -> { where(state: 'en_instruction') }
|
||||
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
|
||||
scope :state_instruction_commencee, -> { where(state: INSTRUCTION_COMMENCEE) }
|
||||
scope :state_termine, -> { where(state: TERMINE) }
|
||||
|
||||
scope :archived, -> { where(archived: true) }
|
||||
|
@ -126,6 +127,10 @@ class Dossier < ApplicationRecord
|
|||
TERMINE.include?(state)
|
||||
end
|
||||
|
||||
def instruction_commencee?
|
||||
INSTRUCTION_COMMENCEE.include?(state)
|
||||
end
|
||||
|
||||
def cerfa_available?
|
||||
procedure.cerfa_flag? && cerfa.size != 0
|
||||
end
|
||||
|
@ -276,7 +281,8 @@ class Dossier < ApplicationRecord
|
|||
now = Time.now
|
||||
deleted_dossier = DeletedDossier.create!(dossier_id: id, procedure: procedure, state: state, deleted_at: now)
|
||||
update(hidden_at: now)
|
||||
deleted_dossier
|
||||
DossierMailer.notify_deletion_to_user(deleted_dossier, user.email).deliver_later
|
||||
DossierMailer.notify_deletion_to_administration(deleted_dossier, procedure.administrateur.email).deliver_later
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
class PrevisualisationService
|
||||
def self.delete_all_champs(dossier)
|
||||
Champ.where(dossier_id: dossier.id, type_de_champ_id: dossier.procedure.types_de_champ.ids).delete_all
|
||||
end
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
.row.white-back
|
||||
#previsualisation
|
||||
= render partial: 'users/description/show', locals: { previsualisation: true }
|
13
app/views/dossier_mailer/notify_unhide_to_user.html.haml
Normal file
13
app/views/dossier_mailer/notify_unhide_to_user.html.haml
Normal file
|
@ -0,0 +1,13 @@
|
|||
- content_for(:title, "Votre dossier n° #{@dossier.id} n'a pas pu être supprimé")
|
||||
|
||||
%h1 Bonjour,
|
||||
|
||||
%p
|
||||
L'instruction de votre dossier n° #{@dossier.id} ayant commencé, il n'a pas pu être supprimé.
|
||||
Le dossier a été rétabli dans votre tableau de bord.
|
||||
|
||||
%p
|
||||
Bonne journée,
|
||||
|
||||
%p
|
||||
L'équipe demarches-simplifiees.fr
|
|
@ -45,7 +45,7 @@
|
|||
.procedure-list-element{ class: ('active' if active == 'E-mails') }
|
||||
E-mails
|
||||
|
||||
%a#onglet-preview{ href: url_for(admin_procedure_previsualisation_path(@procedure)) }
|
||||
%a#onglet-preview{ href: url_for(apercu_procedure_path(@procedure)), target: "_blank" }
|
||||
.procedure-list-element{ class: ('active' if active == 'Prévisualisation') }
|
||||
Prévisualisation
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
.dossier-state= @facade.dossier.display_state
|
||||
.split-hr-left
|
||||
|
||||
- if current_user.owns?(@facade.dossier)
|
||||
- if current_user.owns?(@facade.dossier) && !@facade.dossier.instruction_commencee?
|
||||
.text-center.mt-1
|
||||
= link_to ask_deletion_dossier_path(@facade.dossier), method: :post, class: "btn btn-danger", data: { confirm: delete_dossier_confirm(@facade.dossier) } do
|
||||
= link_to ask_deletion_dossier_path(@facade.dossier), method: :post, class: "btn btn-danger", data: { confirm: "Vous vous apprêtez à supprimer votre dossier ainsi que les informations qu’il contient. Nous vous rappelons que toute suppression entraine l’annulation de la démarche en cours. Confirmer la suppression ?" } do
|
||||
Supprimer définitivement
|
||||
%br
|
||||
ce dossier
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Pour vous aider à remplir votre dossier, vous pouvez consulter
|
||||
= link_to 'le guide de cette démarche', notice_url(dossier.procedure), { target: '_blank' }
|
||||
|
||||
%p.thanks Les champs avec une asterisque (*) sont obligatoires.
|
||||
%p.thanks Les champs avec une astérisque (*) sont obligatoires.
|
||||
|
||||
- if apercu
|
||||
- form_options = { url: '', method: :get, html: { class: 'form', multipart: true } }
|
||||
|
@ -64,6 +64,6 @@
|
|||
data: { action: 'submit', disable_with: 'Envoi...' }
|
||||
|
||||
- else
|
||||
= f.button 'Modifier le dossier',
|
||||
= f.button 'Enregistrer les modifications du dossier',
|
||||
class: 'button send primary',
|
||||
data: { action: 'submit', disable_with: 'Envoi...' }
|
||||
|
|
|
@ -2,5 +2,3 @@
|
|||
{ required: champ.mandatory? },
|
||||
'on',
|
||||
'off'
|
||||
|
||||
%br
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.editable-champ
|
||||
- if is_not_header_nor_explication?(champ)
|
||||
.editable-champ{ class: "editable-champ-#{champ.type_champ}" }
|
||||
- if has_label?(champ)
|
||||
= render partial: 'shared/dossiers/editable_champs/champ_label', locals: { form: form, champ: champ, seen_at: defined?(seen_at) ? seen_at : nil }
|
||||
|
||||
= render partial: "shared/dossiers/editable_champs/#{champ.type_champ}",
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
.container#description-page
|
||||
- if notice_url(@dossier.procedure).present?
|
||||
#lien_notice_panel.row{ style: 'width: 280px; position: fixed; background-color: white; right: 5%; top: 80px; z-index: 200;' }
|
||||
.panel.panel-info{ style: 'margin-bottom: 0;' }
|
||||
.panel-body.center
|
||||
.row
|
||||
.col-xs-1
|
||||
.fa.fa-info-circle.text-info{ style: 'font-size: 2em; margin-top: 20%;' }
|
||||
.col-xs-10{ style: 'padding-right: 0px;' }
|
||||
%b
|
||||
= link_to 'Accéder au guide', notice_url(@dossier.procedure), { target: '_blank' }
|
||||
pour remplir pour votre dossier
|
||||
|
||||
%h2.text-info
|
||||
= @dossier.procedure.libelle
|
||||
|
||||
-# TODO use form_for
|
||||
= form_tag(url_for({ controller: 'users/description', action: :update, dossier_id: @dossier.id }), class: 'form', method: 'POST', multipart: true) do
|
||||
- if @champs.present?
|
||||
#liste-champs
|
||||
= render partial: 'users/description/champs', locals: { private: false }
|
||||
|
||||
- if @procedure.lien_demarche.present? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
|
||||
%br
|
||||
%h3 Pièces jointes
|
||||
|
||||
|
||||
-# TODO a refactorer
|
||||
.row
|
||||
.col-lg-8
|
||||
= render partial: 'users/description/pieces_justificatives', locals: { dossier: @dossier }
|
||||
|
||||
- if !previsualisation
|
||||
%div{ style: 'text-align: right;' }
|
||||
%h6 Tous les champs portant un * sont obligatoires.
|
||||
|
||||
- if !@dossier.can_be_en_construction?
|
||||
.alert.alert-danger
|
||||
= t('errors.messages.procedure_archived')
|
||||
- elsif !@dossier.brouillon?
|
||||
= render partial: '/layouts/modifications_terminees'
|
||||
- else
|
||||
= hidden_field_tag 'submit_action', 'brouillon'
|
||||
= submit_tag 'Bonjour Active Storage !', style: 'display: none;'
|
||||
= button_tag 'Soumettre mon dossier',
|
||||
id: 'suivant',
|
||||
type: 'submit',
|
||||
class: 'btn btn btn-success',
|
||||
style: 'float: right;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'nouveaux' }
|
||||
= button_tag 'Enregistrer un brouillon',
|
||||
id: 'brouillon',
|
||||
type: 'submit',
|
||||
class: 'btn btn-xs btn-default',
|
||||
style: 'float: right; margin-right: 10px; margin-top: 6px;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'brouillon' }
|
||||
= button_tag "Enregistrer et voir mes dossiers",
|
||||
id: 'brouillon_then_dashboard',
|
||||
type: 'submit',
|
||||
class: 'btn btn-xs btn-default',
|
||||
style: 'float: right; margin-right: 10px; margin-top: 6px;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'brouillon_then_dashboard' }
|
|
@ -1 +1,64 @@
|
|||
= render partial: 'show', locals: { previsualisation: false }
|
||||
.container#description-page
|
||||
- if notice_url(@dossier.procedure).present?
|
||||
#lien_notice_panel.row{ style: 'width: 280px; position: fixed; background-color: white; right: 5%; top: 80px; z-index: 200;' }
|
||||
.panel.panel-info{ style: 'margin-bottom: 0;' }
|
||||
.panel-body.center
|
||||
.row
|
||||
.col-xs-1
|
||||
.fa.fa-info-circle.text-info{ style: 'font-size: 2em; margin-top: 20%;' }
|
||||
.col-xs-10{ style: 'padding-right: 0px;' }
|
||||
%b
|
||||
= link_to 'Accéder au guide', notice_url(@dossier.procedure), { target: '_blank' }
|
||||
pour remplir pour votre dossier
|
||||
|
||||
%h2.text-info
|
||||
= @dossier.procedure.libelle
|
||||
|
||||
-# TODO use form_for
|
||||
= form_tag(url_for({ controller: 'users/description', action: :update, dossier_id: @dossier.id }), class: 'form', method: 'POST', multipart: true) do
|
||||
- if @champs.present?
|
||||
#liste-champs
|
||||
= render partial: 'users/description/champs', locals: { private: false }
|
||||
|
||||
- if @procedure.lien_demarche.present? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
|
||||
%br
|
||||
%h3 Pièces jointes
|
||||
|
||||
|
||||
-# TODO a refactorer
|
||||
.row
|
||||
.col-lg-8
|
||||
= render partial: 'users/description/pieces_justificatives', locals: { dossier: @dossier }
|
||||
|
||||
%div{ style: 'text-align: right;' }
|
||||
%h6 Tous les champs portant un * sont obligatoires.
|
||||
|
||||
- if !@dossier.can_be_en_construction?
|
||||
.alert.alert-danger
|
||||
= t('errors.messages.procedure_archived')
|
||||
- elsif !@dossier.brouillon?
|
||||
= render partial: '/layouts/modifications_terminees'
|
||||
- else
|
||||
= hidden_field_tag 'submit_action', 'brouillon'
|
||||
= submit_tag 'Bonjour Active Storage !', style: 'display: none;'
|
||||
= button_tag 'Soumettre mon dossier',
|
||||
id: 'suivant',
|
||||
type: 'submit',
|
||||
class: 'btn btn btn-success',
|
||||
style: 'float: right;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'nouveaux' }
|
||||
= button_tag 'Enregistrer un brouillon',
|
||||
id: 'brouillon',
|
||||
type: 'submit',
|
||||
class: 'btn btn-xs btn-default',
|
||||
style: 'float: right; margin-right: 10px; margin-top: 6px;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'brouillon' }
|
||||
= button_tag "Enregistrer et voir mes dossiers",
|
||||
id: 'brouillon_then_dashboard',
|
||||
type: 'submit',
|
||||
class: 'btn btn-xs btn-default',
|
||||
style: 'float: right; margin-right: 10px; margin-top: 6px;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'brouillon_then_dashboard' }
|
||||
|
|
8
config/france_connect.example.yml
Normal file
8
config/france_connect.example.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
particulier_identifier: ''
|
||||
particulier_secret: ''
|
||||
|
||||
particulier_redirect_uri: ''
|
||||
particulier_authorization_endpoint: ''
|
||||
particulier_token_endpoint: ''
|
||||
particulier_userinfo_endpoint: ''
|
||||
particulier_logout_endpoint: ''
|
2
config/github_secrets.example.yml
Normal file
2
config/github_secrets.example.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
client_id: ''
|
||||
client_secret: ''
|
|
@ -181,8 +181,6 @@ Rails.application.routes.draw do
|
|||
|
||||
resource :accompagnateurs, only: [:show, :update]
|
||||
|
||||
resource :previsualisation, only: [:show]
|
||||
|
||||
resource :attestation_template, only: [:edit, :update, :create]
|
||||
|
||||
post 'attestation_template/disactivate' => 'attestation_templates#disactivate'
|
||||
|
|
11
lib/tasks/2018_06_13_unhide_dossiers.rake
Normal file
11
lib/tasks/2018_06_13_unhide_dossiers.rake
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace :'2018_06_13_unhide_dossiers' do
|
||||
task run: :environment do
|
||||
Dossier.unscoped.where.not(hidden_at: nil).state_instruction_commencee.each do |d|
|
||||
if !d.procedure.nil? # ensure the procedure was not deleted by administrateur for testing
|
||||
d.update(hidden_at: nil)
|
||||
DeletedDossier.find_by(dossier_id: d.id)&.destroy
|
||||
DossierMailer.notify_unhide_to_user(d).deliver_later
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
34
lib/tasks/support.rake
Normal file
34
lib/tasks/support.rake
Normal file
|
@ -0,0 +1,34 @@
|
|||
require Rails.root.join("lib", "tasks", "task_helper")
|
||||
|
||||
namespace :support do
|
||||
desc <<~EOD
|
||||
Give procedure #PROCEDURE_ID a new owner.
|
||||
The owner can be specified with NEW_OWNER_ID or NEW_OWNER_MAIL.
|
||||
EOD
|
||||
task transfer_procedure_ownership: :environment do
|
||||
new_owner_id = ENV['NEW_OWNER_ID']
|
||||
new_owner_mail = ENV['NEW_OWNER_MAIL']
|
||||
|
||||
new_owner = nil
|
||||
if new_owner_id.present?
|
||||
new_owner = Administrateur.find(new_owner_id)
|
||||
elsif new_owner_mail.present?
|
||||
new_owner = Administrateur.find_by(email: new_owner_mail)
|
||||
end
|
||||
|
||||
if new_owner.blank?
|
||||
fail "Must specify a new owner"
|
||||
end
|
||||
|
||||
procedure_id = ENV['PROCEDURE_ID']
|
||||
procedure = Procedure.find(procedure_id)
|
||||
|
||||
rake_puts("Changing owner of procedure ##{procedure_id} from ##{procedure.administrateur_id} to ##{new_owner.id}")
|
||||
procedure.update(administrateur: new_owner)
|
||||
|
||||
ProcedurePath.where(procedure_id: procedure_id).each do |pp|
|
||||
rake_puts("Changing owner of procedure_path #{pp.path} from ##{pp.administrateur_id} to ##{new_owner.id}")
|
||||
pp.update(administrateur: new_owner)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::PrevisualisationsController, type: :controller do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:procedure) { create :procedure, administrateur: admin }
|
||||
|
||||
before do
|
||||
sign_in admin
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
subject { get :show, params: { procedure_id: procedure.id } }
|
||||
it { expect(subject.status).to eq(200) }
|
||||
end
|
||||
end
|
|
@ -412,6 +412,20 @@ describe NewUser::DossiersController, type: :controller do
|
|||
|
||||
subject { post :ask_deletion, params: { id: dossier.id } }
|
||||
|
||||
shared_examples_for "the dossier can not be deleted" do
|
||||
it do
|
||||
expect(DossierMailer).not_to receive(:notify_deletion_to_administration)
|
||||
expect(DossierMailer).not_to receive(:notify_deletion_to_user)
|
||||
subject
|
||||
end
|
||||
|
||||
it do
|
||||
subject
|
||||
expect(Dossier.find_by(id: dossier.id)).not_to eq(nil)
|
||||
expect(dossier.procedure.deleted_dossiers.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is owned by signed in user' do
|
||||
let(:dossier) { create(:dossier, user: user, autorisation_donnees: true) }
|
||||
|
||||
|
@ -429,25 +443,22 @@ describe NewUser::DossiersController, type: :controller do
|
|||
expect(procedure.deleted_dossiers.count).to eq(1)
|
||||
expect(procedure.deleted_dossiers.first.dossier_id).to eq(dossier_id)
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to(users_dossiers_path) }
|
||||
|
||||
context "and the instruction has started" do
|
||||
let(:dossier) { create(:dossier, :en_instruction, user: user, autorisation_donnees: true) }
|
||||
|
||||
it_behaves_like "the dossier can not be deleted"
|
||||
it { is_expected.to redirect_to(users_dossier_path(dossier)) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is not owned by signed in user' do
|
||||
let(:user2) { create(:user) }
|
||||
let(:dossier) { create(:dossier, user: user2, autorisation_donnees: true) }
|
||||
|
||||
it do
|
||||
expect(DossierMailer).not_to receive(:notify_deletion_to_administration)
|
||||
expect(DossierMailer).not_to receive(:notify_deletion_to_user)
|
||||
subject
|
||||
end
|
||||
|
||||
it do
|
||||
subject
|
||||
expect(Dossier.find_by(id: dossier.id)).not_to eq(nil)
|
||||
expect(dossier.procedure.deleted_dossiers.count).to eq(0)
|
||||
end
|
||||
|
||||
it_behaves_like "the dossier can not be deleted"
|
||||
it { is_expected.to redirect_to(root_path) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -71,10 +71,12 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
|
|||
page.find_by_id('add_piece_justificative').click
|
||||
page.find_by_id('procedure_types_de_piece_justificative_attributes_1_libelle')
|
||||
|
||||
page.find_by_id('onglet-preview').click
|
||||
expect(page).to have_current_path(admin_procedure_previsualisation_path(Procedure.first.id.to_s))
|
||||
expect(page.find("input[type='text']")['placeholder']).to eq('libelle de champ')
|
||||
expect(page.first('.piece-libelle').text).to eq('libelle de piece')
|
||||
preview_window = window_opened_by { page.find_by_id('onglet-preview').click }
|
||||
within_window(preview_window) do
|
||||
expect(page).to have_current_path(apercu_procedure_path(Procedure.first))
|
||||
expect(page.find("input[type='text']")['placeholder']).to eq('libelle de champ')
|
||||
expect(page.first('.pj-input label').text).to eq('libelle de piece')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'After adding champ and file, check impossibility to publish procedure, add accompagnateur and make publication' do
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PrevisualisationService do
|
||||
describe '.delete_all_champs' do
|
||||
subject { described_class.delete_all_champs dossier }
|
||||
|
||||
let(:procedure_1) { create :procedure, :with_type_de_champ }
|
||||
let(:procedure_2) { create :procedure, :with_type_de_champ }
|
||||
|
||||
let!(:dossier_1) { create :dossier, procedure: procedure_1 }
|
||||
let!(:dossier_2) { create :dossier, procedure: procedure_2 }
|
||||
|
||||
it { expect(Dossier.all.size).to eq 2 }
|
||||
it { expect(TypeDeChamp.all.size).to eq 2 }
|
||||
it { expect(Champ.all.size).to eq 2 }
|
||||
|
||||
context 'when function delete_all_champs is call' do
|
||||
let(:dossier) { dossier_1 }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(Dossier.all.size).to eq 2 }
|
||||
it { expect(TypeDeChamp.all.size).to eq 2 }
|
||||
it { expect(Champ.all.size).to eq 1 }
|
||||
it { expect(Champ.first.type_de_champ).to eq procedure_2.types_de_champ.first }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,131 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/previsualisations/show.html.haml', type: :view do
|
||||
before do
|
||||
@request.env['HTTP_REFERER'] = admin_procedures_url
|
||||
end
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:cerfa_flag) { true }
|
||||
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: cerfa_flag) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, user: user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
assign(:dossier, dossier)
|
||||
assign(:procedure, dossier.procedure)
|
||||
assign(:champs, dossier.ordered_champs)
|
||||
end
|
||||
|
||||
context 'tous les attributs sont présents sur la page' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
it 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]")
|
||||
end
|
||||
|
||||
it 'Charger votre CERFA (PDF)' do
|
||||
expect(rendered).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]')
|
||||
end
|
||||
|
||||
it 'Lien CERFA' do
|
||||
expect(rendered).to have_selector('#lien_cerfa')
|
||||
end
|
||||
end
|
||||
|
||||
context 'si la page précédente n\'est pas recapitulatif' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
it 'le bouton "Terminer" n\'est pas présent' do
|
||||
expect(rendered).not_to have_selector('#suivant')
|
||||
end
|
||||
end
|
||||
|
||||
context 'si la page précédente est recapitularif' do
|
||||
before do
|
||||
dossier.en_construction!
|
||||
dossier.reload
|
||||
render
|
||||
end
|
||||
|
||||
it 'le bouton "Terminer" n\'est pas présent' do
|
||||
expect(rendered).to_not have_selector('#suivant')
|
||||
end
|
||||
|
||||
it 'le bouton "Modification terminé" n\'est pas présent' do
|
||||
expect(rendered).not_to have_selector('#modification_terminee')
|
||||
end
|
||||
|
||||
it 'le lien de retour au récapitulatif n\'est pas présent' do
|
||||
expect(rendered).not_to have_selector("a[href='/users/dossiers/#{dossier_id}/recapitulatif']")
|
||||
end
|
||||
end
|
||||
|
||||
context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do
|
||||
let!(:dossier) do
|
||||
create(:dossier, user: user)
|
||||
end
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
end
|
||||
|
||||
context 'Champs' do
|
||||
let(:champs) { dossier.champs }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
describe 'first champs' do
|
||||
subject { dossier.champs.first }
|
||||
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
||||
end
|
||||
|
||||
describe 'last champs' do
|
||||
subject { dossier.champs.last }
|
||||
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
||||
end
|
||||
end
|
||||
|
||||
context 'Pièces justificatives' do
|
||||
let(:all_type_pj_procedure_id) { dossier.procedure.type_de_piece_justificative_ids }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
context 'la liste des pièces justificatives a envoyé est affichée' do
|
||||
it 'RIB' do
|
||||
expect(rendered).to have_css("#piece_justificative_#{all_type_pj_procedure_id[0]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Envoi des CERFA désactivé' do
|
||||
let!(:cerfa_flag) { false }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to_not have_css("#cerfa_flag") }
|
||||
it { expect(rendered).to_not have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') }
|
||||
end
|
||||
|
||||
describe 'display title Documents administratifs' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
let(:procedure) { create :procedure, lien_demarche: '' }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
context 'when dossier not have cerfa, piece justificative and demarche link' do
|
||||
it { expect(rendered).not_to have_content 'Documents administratifs' }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue