Merge pull request #2173 from betagouv/dev

2018-06-29-01
This commit is contained in:
Frederic Merizen 2018-06-29 10:11:04 +02:00 committed by GitHub
commit ef5957f021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 186 additions and 444 deletions

View file

@ -2,7 +2,6 @@ $(document).on('turbolinks:load', button_edit_procedure_init);
function button_edit_procedure_init(){ function button_edit_procedure_init(){
buttons_api_carto(); buttons_api_carto();
button_cerfa();
button_individual(); button_individual();
} }
@ -16,16 +15,6 @@ function buttons_api_carto () {
$("#modules-api-carto").show(); $("#modules-api-carto").show();
} }
function button_cerfa () {
$("#procedure_cerfa_flag").on('change', function() {
$("#procedure-lien-demarche").toggle()
});
if ($('#procedure_cerfa_flag').is(':checked'))
$("#procedure-lien-demarche").show();
}
function button_individual () { function button_individual () {
$("#procedure_for_individual").on('change', function() { $("#procedure_for_individual").on('change', function() {

View file

@ -237,7 +237,7 @@ class Admin::ProceduresController < AdminController
if @procedure&.locked? if @procedure&.locked?
params.require(:procedure).permit(*editable_params) params.require(:procedure).permit(*editable_params)
else else
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :lien_demarche, :cerfa_flag, :for_individual, :individual_with_siret, :ask_birthday, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id) params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :lien_demarche, :for_individual, :individual_with_siret, :ask_birthday, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
end end
end end

View file

@ -31,11 +31,6 @@ class Users::DescriptionController < UsersController
ChampsService.save_champs(dossier.champs, params) if params[:champs] ChampsService.save_champs(dossier.champs, params) if params[:champs]
if procedure.cerfa_flag? && params[:cerfa_pdf]
cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: dossier, user: current_user)
return redirect_to_description_with_errors(dossier, cerfa.errors.full_messages) if !cerfa.save
end
errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params) + ChampsService.check_piece_justificative_files(dossier.champs) errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params) + ChampsService.check_piece_justificative_files(dossier.champs)
return redirect_to_description_with_errors(dossier, errors_upload) if errors_upload.any? return redirect_to_description_with_errors(dossier, errors_upload) if errors_upload.any?
@ -68,15 +63,6 @@ class Users::DescriptionController < UsersController
@dossier ||= Dossier.find(params[:dossier_id]) if invite @dossier ||= Dossier.find(params[:dossier_id]) if invite
@dossier ||= current_user_dossier @dossier ||= current_user_dossier
if @dossier.procedure.cerfa_flag?
if params[:cerfa_pdf].present?
cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user)
if !cerfa.save
flash.alert = cerfa.errors.full_messages
end
end
end
if (errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).present? if (errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).present?
if flash.alert.nil? if flash.alert.nil?
flash.alert = errors_upload flash.alert = errors_upload

View file

@ -37,10 +37,6 @@ class DossierFacades
@dossier.procedure @dossier.procedure
end end
def cerfas_ordered
@dossier.cerfa.order('created_at DESC')
end
def invites def invites
@dossier.invites @dossier.invites
end end

View file

@ -1,21 +0,0 @@
class Cerfa < ApplicationRecord
belongs_to :dossier, touch: true
belongs_to :user
mount_uploader :content, CerfaUploader
validates :content, :file_size => { :maximum => 20.megabytes }
def empty?
content.blank?
end
def content_url
if content.url.present?
if Flipflop.remote_storage?
(RemoteDownloader.new content.filename).url
else
(LocalDownloader.new content.path, 'CERFA').url
end
end
end
end

View file

@ -28,8 +28,24 @@ class Champs::LinkedDropDownListChamp < Champ
:primary_value :primary_value
end end
def for_display
string_value
end
def mandatory_and_blank?
mandatory? && (primary_value.blank? || secondary_value.blank?)
end
private private
def string_value
[primary_value, secondary_value].compact.join(' / ')
end
def value_for_export
"#{primary_value || ''};#{secondary_value || ''}"
end
def pack_value def pack_value
self.value = JSON.generate([ primary_value, secondary_value ]) self.value = JSON.generate([ primary_value, secondary_value ])
end end

View file

@ -16,7 +16,6 @@ class Dossier < ApplicationRecord
has_one :etablissement, dependent: :destroy has_one :etablissement, dependent: :destroy
has_one :individual, dependent: :destroy has_one :individual, dependent: :destroy
has_one :attestation has_one :attestation
has_many :cerfa, dependent: :destroy
has_many :pieces_justificatives, dependent: :destroy has_many :pieces_justificatives, dependent: :destroy
has_many :champs, -> { public_only }, dependent: :destroy has_many :champs, -> { public_only }, dependent: :destroy
@ -127,10 +126,6 @@ class Dossier < ApplicationRecord
INSTRUCTION_COMMENCEE.include?(state) INSTRUCTION_COMMENCEE.include?(state)
end end
def cerfa_available?
procedure.cerfa_flag? && cerfa.size != 0
end
def export_headers def export_headers
serialized_dossier = DossierTableExportSerializer.new(self) serialized_dossier = DossierTableExportSerializer.new(self)
headers = serialized_dossier.attributes.keys headers = serialized_dossier.attributes.keys

View file

@ -222,6 +222,10 @@ class Procedure < ApplicationRecord
procedure.cloned_from_library = from_library procedure.cloned_from_library = from_library
procedure.parent_procedure = self procedure.parent_procedure = self
if from_library
procedure.service = nil
end
procedure procedure
end end

View file

@ -16,7 +16,6 @@ class User < ApplicationRecord
has_many :invites, dependent: :destroy has_many :invites, dependent: :destroy
has_many :dossiers_invites, through: :invites, source: :dossier has_many :dossiers_invites, through: :invites, source: :dossier
has_many :piece_justificative, dependent: :destroy has_many :piece_justificative, dependent: :destroy
has_many :cerfa, dependent: :destroy
has_one :france_connect_information, dependent: :destroy has_one :france_connect_information, dependent: :destroy
delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information

View file

@ -1,6 +0,0 @@
class CerfaSerializer < ActiveModel::Serializer
attributes :created_at,
:content_url
has_one :user
end

View file

@ -0,0 +1,5 @@
class Champs::LinkedDropDownListChampSerializer < ChampSerializer
def value
{ primary: object.primary_value, secondary: object.secondary_value }
end
end

View file

@ -30,6 +30,10 @@ class DossierSerializer < ActiveModel::Serializer
champs champs
end end
def cerfa
[]
end
def email def email
object.user&.email object.user&.email
end end

View file

@ -1,49 +0,0 @@
class CerfaUploader < BaseUploader
before :cache, :set_original_filename
# Choose what kind of storage to use for this uploader:
if Flipflop.remote_storage?
storage :fog
else
storage :file
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
if !Flipflop.remote_storage?
"./uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(pdf doc docx xls xlsx ppt pptx odt ods odp jpg jpeg png)
end
def filename
if original_filename.present? || model.content_secure_token
if Flipflop.remote_storage?
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
else
filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}"
end
end
filename
end
private
def secure_token
model.content_secure_token ||= generate_secure_token
end
def generate_secure_token
SecureRandom.uuid
end
def set_original_filename(file)
model.original_filename ||= file.original_filename if file.respond_to?(:original_filename)
end
end

View file

@ -106,14 +106,6 @@
Cadastre Cadastre
.col-md-6 .col-md-6
- if @procedure.cerfa_flag
%h4 Formulaire de demande ou CERFA
.checkbox
%label
= f.check_box :cerfa_flag
Activer l'envoi de formulaire de demande ou CERFA
%br
= f.text_field :lien_demarche, class: 'form-control', placeholder: 'URL vers le formulaire vierge (facultatif)'
.row .row
.col-md-6 .col-md-6

View file

@ -1,6 +1,6 @@
- if !@facade.dossier.read_only? - if !@facade.dossier.read_only?
- if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier)) - if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier))
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0 - if @facade.dossier.types_de_piece_justificative.size > 0
.col-lg-4.col-md-4.col-sm-4.col-xs-4.action .col-lg-4.col-md-4.col-sm-4.col-xs-4.action
%a#maj_pj.action{ "data-target" => "#upload-pj-modal", %a#maj_pj.action{ "data-target" => "#upload-pj-modal",
"data-toggle" => "modal", "data-toggle" => "modal",

View file

@ -50,11 +50,13 @@
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true } = render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true }
- elsif champ.type_champ == 'textarea' - elsif champ.type_champ == 'textarea'
= simple_format(champ.decorate.value) = simple_format(champ.decorate.value)
- elsif champ.type_champ == 'linked_drop_down_list'
= champ.for_display
- else - else
= sanitize(champ.decorate.value) = sanitize(champ.decorate.value)
.row .row
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.count > 0 - if @facade.dossier.types_de_piece_justificative.count > 0
.col-xs-12 .col-xs-12
.row.title-row .row.title-row
.col-xs-4.split-hr .col-xs-4.split-hr
@ -62,21 +64,6 @@
.col-xs-4.split-hr .col-xs-4.split-hr
.col-xs-12#pieces-justificatives.margin-bot-40 .col-xs-12#pieces-justificatives.margin-bot-40
.row
- if @facade.procedure.cerfa_flag?
.col-xs-12#piece_justificative_0
.row.piece-row
.col-xs-6.depositaire-label= 'Formulaire'
.col-xs-1.comments-off= "-"
.col-xs-5.despositaire-info
- if @facade.dossier.cerfa_available?
%a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter
%span{ style: 'margin-left: 12px;' }
\-
= link_to "", class: "historique", "data-toggle" => "modal", "data-target" => "#pj-modal", :type => "button", "data-modal_title" => 'formulaires', "data-modal_index" => 'cerfa' do
%span.fa.fa-clock-o
- else
Pièce non fournie
.row .row
.col-xs-12 .col-xs-12
- @facade.types_de_pieces_justificatives.each do |type_de_piece_justificative| - @facade.types_de_pieces_justificatives.each do |type_de_piece_justificative|
@ -100,7 +87,7 @@
- if !@facade.dossier.read_only? - if !@facade.dossier.read_only?
- if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier)) - if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier))
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0 - if @facade.dossier.types_de_piece_justificative.size > 0
.row .row
.col-xs-4 .col-xs-4
%a#maj_pj.action{ "data-target" => "#upload-pj-modal", "data-toggle" => "modal", :type => "button" } %a#maj_pj.action{ "data-target" => "#upload-pj-modal", "data-toggle" => "modal", :type => "button" }
@ -130,16 +117,6 @@
%th %th
Lien Lien
%thead.tr-content#cerfa %thead.tr-content#cerfa
- if @facade.procedure.cerfa_flag?
- if @facade.dossier.cerfa_available?
- @facade.cerfas_ordered.each do |cerfa|
%tr
%td.col-md-6.col-sm-6.col-xs-6.col-lg-4
= cerfa.user.email
%td.col-md-6.col-sm-6.col-xs-6.col-lg-4
= cerfa.created_at
%td.col-md-6.col-sm-6.col-xs-6.col-lg-4
= link_to 'Récupérer', cerfa.content_url, { target: :blank }
- @facade.dossier.types_de_piece_justificative.each do |type_de_piece_justificative| - @facade.dossier.types_de_piece_justificative.each do |type_de_piece_justificative|
%tbody.tr-content{ id: "type_de_pj_#{type_de_piece_justificative.id}" } %tbody.tr-content{ id: "type_de_pj_#{type_de_piece_justificative.id}" }
- @facade.dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).each do |piece_justificative| - @facade.dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).each do |piece_justificative|

View file

@ -1,24 +1,4 @@
#pieces-justificatives #pieces-justificatives
.row
- if @facade.procedure.cerfa_flag?
.col-xs-12#piece_justificative_0
.row.piece-row
.col-xs-6.piece-label= 'Formulaire'
.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-"
.col-xs-5
- if @facade.dossier.cerfa_available?
%a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter
%span{ style: 'margin-left: 12px;' }
\-
%a.btn.fa.fa-timer{ style: 'color: black; padding-top: 0;',
"data-target" => "#pj-modal",
"data-toggle" => "modal",
:type => "button",
"data-modal_title" => 'formulaires',
"data-modal_index" => 'cerfa' }
- else
= 'Pièce non fournie'
.row .row
.col-xs-12 .col-xs-12
- @facade.dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative| - @facade.dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative|

View file

@ -1,23 +1,5 @@
#pieces-justificatives #pieces-justificatives
%table.table %table.table
- if @facade.procedure.cerfa_flag?
%tr#piece_justificative_0
%th.col-lg-6
Formulaire
%td.col-lg-6.col-md-6.col-sm-6.col-xs-6
- if @facade.dossier.cerfa_available?
%a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter
%span{ style: 'margin-left: 12px;' }
\-
%a.btn.fa.fa-timer{ style: 'color: black; padding-top: 0;',
"data-target" => "#pj-modal",
"data-toggle" => "modal",
:type => "button",
"data-modal_title" => 'formulaires',
"data-modal_index" => 'cerfa' }
- else
Pièce non fournie
- @facade.dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative| - @facade.dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative|
%tr{ id: "piece_justificative_#{type_de_piece_justificative.id}" } %tr{ id: "piece_justificative_#{type_de_piece_justificative.id}" }
%th.col-lg-6 %th.col-lg-6

View file

@ -15,6 +15,10 @@
- c.value.split(", ").each do |item| - c.value.split(", ").each do |item|
%li %li
= item = item
- when "linked_drop_down_list"
%th.libelle
= "#{c.libelle} :"
%td= c.for_display
- when "dossier_link" - when "dossier_link"
%th.libelle %th.libelle
= "#{c.libelle} :" = "#{c.libelle} :"

View file

@ -1,16 +1,5 @@
%table.table.vertical.pj.dossier-champs %table.table.vertical.pj.dossier-champs
%tbody %tbody
- if dossier.procedure.cerfa_flag?
%tr
%th Formulaire :
%td
- if @dossier.cerfa_available?
= link_to "Télécharger", @dossier.cerfa.last.content_url, class: "link", target: :blank
- else
Pièce non fournie
%td
- dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| - dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative|
- pjs = dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).to_ary.dup - pjs = dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).to_ary.dup
- pj = pjs.shift if pjs.present? - pj = pjs.shift if pjs.present?

View file

@ -33,19 +33,10 @@
%tr %tr
%td= "Parcelle n° #{p.numero} - Feuille #{p.code_arr} #{p.section} #{p.feuille}" %td= "Parcelle n° #{p.numero} - Feuille #{p.code_arr} #{p.section} #{p.feuille}"
- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? - if @dossier.types_de_piece_justificative.any?
%h3 Pièces jointes %h3 Pièces jointes
%table %table
- if @dossier.procedure.cerfa_flag?
%tr
%th Formulaire :
%td
- if @dossier.cerfa_available?
Pièce fournie
- else
Pièce non fournie
- @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| - @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative|
%tr %tr
%th= "#{type_de_piece_justificative.libelle} :" %th= "#{type_de_piece_justificative.libelle} :"

View file

@ -20,7 +20,7 @@
.card .card
= render partial: "new_gestionnaire/dossiers/map", locals: { dossier: dossier } = render partial: "new_gestionnaire/dossiers/map", locals: { dossier: dossier }
- if dossier.procedure.cerfa_flag? || dossier.types_de_piece_justificative.any? - if dossier.types_de_piece_justificative.any?
.tab-title Pièces jointes .tab-title Pièces jointes
.card .card
= render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: dossier, demande_seen_at: demande_seen_at } = render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: dossier, demande_seen_at: demande_seen_at }

View file

@ -1,23 +1,4 @@
%table.table %table.table
- if dossier.procedure.cerfa_flag
%tr
%th
Formulaire de demande ou CERFA (complété et numérisé)
%td
- if dossier.procedure.lien_demarche.present?
%em
Récupérer le formulaire de demande ou CERFA vierge pour mon dossier :
= link_to "Télécharger", sanitize_url(dossier.procedure.lien_demarche), target: :blank, id: :lien_cerfa
-# %a#lien_cerfa{ href: "#{dossier.procedure.lien_demarche}", target: '_blank' } Télécharger
%td
- if dossier.cerfa_available?
%span.btn.btn-sm.btn-file.btn-success
Modifier
%input#cerfa_pdf{ type: 'file', name: 'cerfa_pdf', accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes }
- else
%input#cerfa_pdf{ type: 'file', name: 'cerfa_pdf', accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes }
- dossier.types_de_piece_justificative.order('order_place ASC').each do |tpj| - dossier.types_de_piece_justificative.order('order_place ASC').each do |tpj|
%tr %tr
%th.piece-libelle %th.piece-libelle

View file

@ -20,7 +20,7 @@
#liste-champs #liste-champs
= render partial: 'users/description/champs', locals: { private: false } = render partial: 'users/description/champs', locals: { private: false }
- if @procedure.lien_demarche.present? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0 - if @procedure.lien_demarche.present? || @dossier.types_de_piece_justificative.size > 0
%br %br
%h3 Pièces jointes %h3 Pièces jointes

View file

@ -102,10 +102,6 @@ fr:
attributes: attributes:
content: content:
size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 20Mo." size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 20Mo."
cerfa:
attributes:
content:
size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 20Mo."
user: user:
attributes: attributes:
reset_password_token: reset_password_token:

View file

@ -0,0 +1,9 @@
class UpdateSearchesToVersion4 < ActiveRecord::Migration[5.2]
def up
replace_view :searches, version: 4
end
def down
replace_view :searches, version: 3
end
end

View file

@ -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: 2018_06_01_084546) do ActiveRecord::Schema.define(version: 2018_06_27_092237) 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"
@ -632,11 +632,10 @@ ActiveRecord::Schema.define(version: 2018_06_01_084546) do
create_view "searches", sql_definition: <<-SQL create_view "searches", sql_definition: <<-SQL
SELECT dossiers.id AS dossier_id, SELECT dossiers.id AS dossier_id,
(((((((((((((((((((((((((((((((((((((((((((((((((((((((COALESCE(users.email, ''::character varying))::text || ' '::text) || (COALESCE(france_connect_informations.given_name, ''::character varying))::text) || ' '::text) || (COALESCE(france_connect_informations.family_name, ''::character varying))::text) || ' '::text) || (COALESCE(cerfas.content, ''::character varying))::text) || ' '::text) || (COALESCE(champs.value, ''::character varying))::text) || ' '::text) || (COALESCE(drop_down_lists.value, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siren, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique_code, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom_commercial, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_raison_sociale, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siret_siege_social, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_prenom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_rna, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_titre, ''::character varying))::text) || ' '::text) || COALESCE(etablissements.association_objet, ''::text)) || ' '::text) || (COALESCE(etablissements.siret, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.libelle_naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.adresse, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_postal, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.localite, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_insee_localite, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.nom, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(pieces_justificatives.content, ''::character varying))::text) AS term (((((((((((((((((((((((((((((((((((((((((((((((((((((COALESCE(users.email, ''::character varying))::text || ' '::text) || (COALESCE(france_connect_informations.given_name, ''::character varying))::text) || ' '::text) || (COALESCE(france_connect_informations.family_name, ''::character varying))::text) || ' '::text) || (COALESCE(champs.value, ''::character varying))::text) || ' '::text) || (COALESCE(drop_down_lists.value, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siren, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique_code, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom_commercial, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_raison_sociale, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siret_siege_social, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_prenom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_rna, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_titre, ''::character varying))::text) || ' '::text) || COALESCE(etablissements.association_objet, ''::text)) || ' '::text) || (COALESCE(etablissements.siret, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.libelle_naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.adresse, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_postal, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.localite, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_insee_localite, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.nom, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(pieces_justificatives.content, ''::character varying))::text) AS term
FROM ((((((((dossiers FROM (((((((dossiers
JOIN users ON ((users.id = dossiers.user_id))) JOIN users ON ((users.id = dossiers.user_id)))
LEFT JOIN france_connect_informations ON ((france_connect_informations.user_id = dossiers.user_id))) LEFT JOIN france_connect_informations ON ((france_connect_informations.user_id = dossiers.user_id)))
LEFT JOIN cerfas ON ((cerfas.dossier_id = dossiers.id)))
LEFT JOIN champs ON ((champs.dossier_id = dossiers.id))) LEFT JOIN champs ON ((champs.dossier_id = dossiers.id)))
LEFT JOIN drop_down_lists ON ((drop_down_lists.type_de_champ_id = champs.type_de_champ_id))) LEFT JOIN drop_down_lists ON ((drop_down_lists.type_de_champ_id = champs.type_de_champ_id)))
LEFT JOIN etablissements ON ((etablissements.dossier_id = dossiers.id))) LEFT JOIN etablissements ON ((etablissements.dossier_id = dossiers.id)))

39
db/views/searches_v04.sql Normal file
View file

@ -0,0 +1,39 @@
-- this version merges all possible search terms together, complicating the
-- view, but enables searching for multiple terms from multiple tables at once.
SELECT dossiers.id AS dossier_id,
COALESCE(users.email, '') || ' ' ||
COALESCE(france_connect_informations.given_name, '') || ' ' ||
COALESCE(france_connect_informations.family_name, '') || ' ' ||
COALESCE(champs.value, '') || ' ' ||
COALESCE(drop_down_lists.value, '') || ' ' ||
COALESCE(etablissements.entreprise_siren, '') || ' ' ||
COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, '') || ' ' ||
COALESCE(etablissements.entreprise_forme_juridique, '') || ' ' ||
COALESCE(etablissements.entreprise_forme_juridique_code, '') || ' ' ||
COALESCE(etablissements.entreprise_nom_commercial, '') || ' ' ||
COALESCE(etablissements.entreprise_raison_sociale, '') || ' ' ||
COALESCE(etablissements.entreprise_siret_siege_social, '') || ' ' ||
COALESCE(etablissements.entreprise_nom, '') || ' ' ||
COALESCE(etablissements.entreprise_prenom, '') || ' ' ||
COALESCE(etablissements.association_rna, '') || ' ' ||
COALESCE(etablissements.association_titre, '') || ' ' ||
COALESCE(etablissements.association_objet, '') || ' ' ||
COALESCE(etablissements.siret, '') || ' ' ||
COALESCE(etablissements.naf, '') || ' ' ||
COALESCE(etablissements.libelle_naf, '') || ' ' ||
COALESCE(etablissements.adresse, '') || ' ' ||
COALESCE(etablissements.code_postal, '') || ' ' ||
COALESCE(etablissements.localite, '') || ' ' ||
COALESCE(etablissements.code_insee_localite, '') || ' ' ||
COALESCE(individuals.nom, '') || ' ' ||
COALESCE(individuals.prenom, '') || ' ' ||
COALESCE(pieces_justificatives.content, '') AS term
FROM dossiers
INNER JOIN users ON users.id = dossiers.user_id
LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id
LEFT JOIN champs ON champs.dossier_id = dossiers.id
LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id
LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id
LEFT JOIN individuals ON individuals.dossier_id = dossiers.id
LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id

View file

@ -11,11 +11,10 @@ describe Admin::ProceduresController, type: :controller do
let(:organisation) { 'Organisation de test' } let(:organisation) { 'Organisation de test' }
let(:direction) { 'Direction de test' } let(:direction) { 'Direction de test' }
let(:lien_demarche) { 'http://localhost.com' } let(:lien_demarche) { 'http://localhost.com' }
let(:cadre_juridique) { 'cadre juridique' }
let(:use_api_carto) { '0' } let(:use_api_carto) { '0' }
let(:quartiers_prioritaires) { '0' } let(:quartiers_prioritaires) { '0' }
let(:cadastre) { '0' } let(:cadastre) { '0' }
let(:cerfa_flag) { true }
let(:cadre_juridique) { 'cadre juridique' }
let(:duree_conservation_dossiers_dans_ds) { 3 } let(:duree_conservation_dossiers_dans_ds) { 3 }
let(:duree_conservation_dossiers_hors_ds) { 6 } let(:duree_conservation_dossiers_hors_ds) { 6 }
@ -26,7 +25,6 @@ describe Admin::ProceduresController, type: :controller do
organisation: organisation, organisation: organisation,
direction: direction, direction: direction,
lien_demarche: lien_demarche, lien_demarche: lien_demarche,
cerfa_flag: cerfa_flag,
cadre_juridique: cadre_juridique, cadre_juridique: cadre_juridique,
duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds, duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds,
duree_conservation_dossiers_hors_ds: duree_conservation_dossiers_hors_ds, duree_conservation_dossiers_hors_ds: duree_conservation_dossiers_hors_ds,
@ -328,7 +326,6 @@ describe Admin::ProceduresController, type: :controller do
it { expect(subject.organisation).to eq procedure_params[:organisation] } it { expect(subject.organisation).to eq procedure_params[:organisation] }
it { expect(subject.direction).to eq procedure_params[:direction] } it { expect(subject.direction).to eq procedure_params[:direction] }
it { expect(subject.cerfa_flag).not_to eq procedure_params[:cerfa_flag] }
it { expect(subject.lien_demarche).not_to eq procedure_params[:lien_demarche] } it { expect(subject.lien_demarche).not_to eq procedure_params[:lien_demarche] }
it { expect(subject.for_individual).not_to eq procedure_params[:for_individual] } it { expect(subject.for_individual).not_to eq procedure_params[:for_individual] }
it { expect(subject.individual_with_siret).not_to eq procedure_params[:individual_with_siret] } it { expect(subject.individual_with_siret).not_to eq procedure_params[:individual_with_siret] }

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe API::V1::DossiersController do describe API::V1::DossiersController do
let(:admin) { create(:administrateur) } let(:admin) { create(:administrateur) }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin, cerfa_flag: true) } let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin) }
let(:wrong_procedure) { create(:procedure) } let(:wrong_procedure) { create(:procedure) }
it { expect(described_class).to be < APIController } it { expect(described_class).to be < APIController }
@ -332,34 +332,6 @@ describe API::V1::DossiersController do
it { expect(subject.first[:email]).to eq 'plop@plip.com' } it { expect(subject.first[:email]).to eq 'plop@plip.com' }
end end
describe 'cerfa', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_cerfa' } do
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :with_cerfa_upload, procedure: procedure) } }
let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
before do
tmp_cerfa = dossier.cerfa.first
tmp_cerfa.content = content
tmp_cerfa.user = dossier.user
tmp_cerfa.save
end
subject { super()[:cerfa].first }
it { expect(subject[:created_at]).not_to be_nil }
if Flipflop.remote_storage?
it { expect(subject[:content_url]).to match(/^https:\/\/storage.apientreprise.fr\/tps_dev\/cerfa-.*\.pdf$/) }
else
it { expect(subject[:content_url]).to match(/^http:\/\/.*downloads.*_CERFA\.pdf$/) }
end
describe 'user' do
let(:field_list) { [:url, :created_at, :type_de_piece_justificative_id] }
subject { super()[:user] }
it { expect(subject[:email]).not_to be_nil }
end
end
describe 'etablissement' do describe 'etablissement' do
let(:field_list) { let(:field_list) {
[ [

View file

@ -190,61 +190,6 @@ shared_examples 'description_controller_spec' do
end end
end end
context 'Quand la procédure accepte les CERFA' do
subject { post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf } }
context 'Sauvegarde du CERFA PDF', vcr: { cassette_name: 'controllers_users_description_controller_save_cerfa' } do
before do
post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf }
dossier.reload
end
context 'when a CERFA PDF is sent', vcr: { cassette_name: 'controllers_users_description_controller_cerfa_is_sent' } do
subject { dossier.cerfa.first }
it 'content' do
if Flipflop.remote_storage?
expect(subject['content']).to eq('cerfa-3dbb3535-5388-4a37-bc2d-778327b9f999.pdf')
else
expect(subject['content']).to eq('cerfa.pdf')
end
end
it 'dossier_id' do
expect(subject.dossier_id).to eq(dossier_id)
end
it { expect(subject.user).to eq user }
end
context 'les anciens CERFA PDF ne sont pas écrasées' do
let(:cerfas) { Cerfa.where(dossier_id: dossier_id) }
before do
post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf }
end
it "il y a deux CERFA PDF pour ce dossier" do
expect(cerfas.size).to eq 2
end
end
end
end
context 'Quand la procédure n\'accepte pas les CERFA' do
context 'Sauvegarde du CERFA PDF' do
let!(:procedure) { create(:procedure) }
before do
post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf }
dossier.reload
end
context 'un CERFA PDF est envoyé' do
it { expect(dossier.cerfa_available?).to be_falsey }
end
end
end
describe 'Sauvegarde des champs' do describe 'Sauvegarde des champs' do
let(:champs_dossier) { dossier.champs } let(:champs_dossier) { dossier.champs }
let(:dossier_text_value) { 'test value' } let(:dossier_text_value) { 'test value' }
@ -288,7 +233,7 @@ shared_examples 'description_controller_spec' do
it { expect(response).to redirect_to users_dossier_recapitulatif_path } it { expect(response).to redirect_to users_dossier_recapitulatif_path }
context 'when champs is mandatory' do context 'when champs is mandatory' do
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ_mandatory, :with_datetime, cerfa_flag: true) } let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ_mandatory, :with_datetime) }
it { expect(response).not_to redirect_to users_dossier_recapitulatif_path } it { expect(response).not_to redirect_to users_dossier_recapitulatif_path }
it { expect(flash[:alert]).to be_present } it { expect(flash[:alert]).to be_present }

View file

@ -9,9 +9,9 @@ describe Users::DescriptionController, type: :controller, vcr: { cassette_name:
let(:state) { 'en_construction' } let(:state) { 'en_construction' }
let(:procedure) do let(:procedure) do
if archived if archived
create(:procedure, :archived, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true) create(:procedure, :archived, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime)
else else
create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true) create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime)
end end
end end
let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) } let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) }
@ -23,7 +23,6 @@ describe Users::DescriptionController, type: :controller, vcr: { cassette_name:
let(:name_piece_justificative_0) { 'piece_justificative_0.pdf' } let(:name_piece_justificative_0) { 'piece_justificative_0.pdf' }
let(:name_piece_justificative_1) { 'piece_justificative_1.pdf' } let(:name_piece_justificative_1) { 'piece_justificative_1.pdf' }
let(:cerfa_pdf) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative}", 'application/pdf') }
let(:piece_justificative_0) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_0}", 'application/pdf') } let(:piece_justificative_0) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_0}", 'application/pdf') }
let(:piece_justificative_1) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_1}", 'application/pdf') } let(:piece_justificative_1) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_1}", 'application/pdf') }

View file

@ -1,4 +0,0 @@
FactoryBot.define do
factory :cerfa do
end
end

View file

@ -45,12 +45,6 @@ FactoryBot.define do
end end
end end
trait :with_cerfa_upload do
after(:build) do |dossier, _evaluator|
dossier.cerfa << create(:cerfa)
end
end
trait :archived do trait :archived do
archived true archived true
end end

View file

@ -8,7 +8,6 @@ FactoryBot.define do
direction "direction DINSIC" direction "direction DINSIC"
cadre_juridique "un cadre juridique important" cadre_juridique "un cadre juridique important"
published_at nil published_at nil
cerfa_flag false
administrateur { create(:administrateur) } administrateur { create(:administrateur) }
duree_conservation_dossiers_dans_ds 3 duree_conservation_dossiers_dans_ds 3
duree_conservation_dossiers_hors_ds 6 duree_conservation_dossiers_hors_ds 6

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
feature 'user is on description page' do feature 'user is on description page' do
let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) } let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ) }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, autorisation_donnees: true) } let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, autorisation_donnees: true) }
before do before do
@ -23,25 +23,12 @@ feature 'user is on description page' do
find_by_id("champs_#{dossier.champs.first.id}").set 'mon nom' find_by_id("champs_#{dossier.champs.first.id}").set 'mon nom'
end end
context 'before submit' do context 'before submit' do
it 'dossier cerfa is empty' do
expect(dossier.cerfa).to be_empty
end
it 'pieces_justificatives are empty' do it 'pieces_justificatives are empty' do
dossier.pieces_justificatives.each do |piece_justificative| dossier.pieces_justificatives.each do |piece_justificative|
expect(piece_justificative).to be_empty expect(piece_justificative).to be_empty
end end
end end
end end
context 'he adds cerfa', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa' } do
before do
attach_file('cerfa_pdf', File.path('spec/support/files/dossierPDF.pdf'))
click_on("Soumettre mon dossier")
dossier.reload
end
it 'fills dossier cerfa' do
expect(dossier.cerfa).not_to be_empty
end
end
context 'when he adds a piece_justificative and submit form', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa_and_submit' } do context 'when he adds a piece_justificative and submit form', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa_and_submit' } do
before do before do
file_input_id = "piece_justificative_#{dossier.types_de_piece_justificative.first.id.to_s}" file_input_id = "piece_justificative_#{dossier.types_de_piece_justificative.first.id.to_s}"

View file

@ -2,8 +2,8 @@ require 'spec_helper'
describe FileSizeValidator, lib: true do describe FileSizeValidator, lib: true do
let(:validator) { FileSizeValidator.new(options) } let(:validator) { FileSizeValidator.new(options) }
let(:attachment) { CerfaUploader.new } let(:attachment) { PieceJustificativeUploader.new }
let(:note) { create(:cerfa) } let(:note) { create(:piece_justificative, :contrat) }
describe 'options uses an integer' do describe 'options uses an integer' do
let(:options) { { maximum: 10, attributes: { content: attachment } } } let(:options) { { maximum: 10, attributes: { content: attachment } } }

View file

@ -1,15 +0,0 @@
require 'spec_helper'
describe Cerfa do
describe 'empty?', vcr: { cassette_name: 'models_cerfa_empty' } do
subject { create(:cerfa, content: content) }
context 'when content exist' do
let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
it { expect(subject).not_to be_empty }
end
context 'when content is nil' do
let(:content) { nil }
it { expect(subject).to be_empty }
end
end
end

View file

@ -15,4 +15,87 @@ describe Champs::LinkedDropDownListChamp do
it { expect(champ.value).to eq('["tata","tutu"]') } it { expect(champ.value).to eq('["tata","tutu"]') }
end end
describe '#for_display' do
let(:champ) { described_class.new(primary_value: primary_value, secondary_value: secondary_value) }
let(:primary_value) { nil }
let(:secondary_value) { nil }
subject { champ.for_display }
context 'with no value' do
it { is_expected.to eq('') }
end
context 'with primary value' do
let(:primary_value) { 'primary' }
it { is_expected.to eq('primary') }
end
context 'with secondary value' do
let(:primary_value) { 'primary' }
let(:secondary_value) { 'secondary' }
it { is_expected.to eq('primary / secondary') }
end
end
describe 'for_export' do
subject { champ.for_export }
context 'with no value' do
let(:champ) { described_class.new }
it { is_expected.to be_nil }
end
context 'with primary value' do
let(:champ) { described_class.new(primary_value: 'primary') }
it { is_expected.to eq('primary;') }
end
context 'with secondary value' do
let(:champ) { described_class.new(primary_value: 'primary', secondary_value: 'secondary') }
it { is_expected.to eq('primary;secondary') }
end
end
describe '#mandatory_and_blank' do
let(:drop_down_list) { build(:drop_down_list, value: "--Primary--\nSecondary") }
subject { described_class.new(type_de_champ: type_de_champ) }
context 'when the champ is not mandatory' do
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, drop_down_list: drop_down_list) }
it 'blank is fine' do
is_expected.not_to be_mandatory_and_blank
end
end
context 'when the champ is mandatory' do
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, mandatory: true, drop_down_list: drop_down_list) }
context 'when there is no value' do
it { is_expected.to be_mandatory_and_blank }
end
context 'when there is a primary value' do
before { subject.primary_value = 'Primary' }
context 'when there is no secondary value' do
it { is_expected.to be_mandatory_and_blank }
end
context 'when there is a secondary value' do
before { subject.secondary_value = 'Primary' }
it { is_expected.not_to be_mandatory_and_blank }
end
end
end
end
end end

View file

@ -41,31 +41,6 @@ describe Dossier do
end end
end end
describe 'creation' do
describe 'Procedure accepts cerfa upload' do
let(:procedure) { create(:procedure, cerfa_flag: true) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, user: user) }
it 'create default cerfa' do
expect { subject.to change(Cerfa.count).by(1) }
expect { subject.cerfa_available.to be_truthy }
end
it 'link cerfa to dossier' do
expect { subject.cerfa.to eq(Cerfa.last) }
end
end
describe 'Procedure does not accept cerfa upload' do
let(:procedure) { create(:procedure, cerfa_flag: false) }
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
it 'default cerfa is not created' do
expect { subject.to change(Cerfa.count).by(0) }
expect { subject.cerfa.to eq(nil) }
expect { subject.cerfa_available.to be_falsey }
end
end
end
describe '#retrieve_last_piece_justificative_by_type', vcr: { cassette_name: 'models_dossier_retrieve_last_piece_justificative_by_type' } do describe '#retrieve_last_piece_justificative_by_type', vcr: { cassette_name: 'models_dossier_retrieve_last_piece_justificative_by_type' } do
let(:types_de_pj_dossier) { dossier.procedure.types_de_piece_justificative } let(:types_de_pj_dossier) { dossier.procedure.types_de_piece_justificative }
@ -133,26 +108,6 @@ describe Dossier do
end end
end end
describe '#cerfa_available?' do
let(:procedure) { create(:procedure, cerfa_flag: cerfa_flag) }
let(:dossier) { create(:dossier, procedure: procedure) }
context 'Procedure accepts CERFA' do
let(:cerfa_flag) { true }
context 'when cerfa is not uploaded' do
it { expect(dossier.cerfa_available?).to be_falsey }
end
context 'when cerfa is uploaded' do
let(:dossier) { create :dossier, :with_cerfa_upload, procedure: procedure }
it { expect(dossier.cerfa_available?).to be_truthy }
end
end
context 'Procedure does not accept CERFA' do
let(:cerfa_flag) { false }
it { expect(dossier.cerfa_available?).to be_falsey }
end
end
describe '#convert_specific_hash_values_to_string(hash_to_convert)' do describe '#convert_specific_hash_values_to_string(hash_to_convert)' 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) }
@ -746,12 +701,6 @@ describe Dossier do
it { is_expected.not_to eq(modif_date) } it { is_expected.not_to eq(modif_date) }
context 'when a cerfa is modified' do
before { dossier.cerfa << create(:cerfa) }
it { is_expected.to eq(modif_date) }
end
context 'when a piece justificative is modified' do context 'when a piece justificative is modified' do
before { dossier.pieces_justificatives << create(:piece_justificative, :contrat) } before { dossier.pieces_justificatives << create(:piece_justificative, :contrat) }

View file

@ -116,7 +116,6 @@ RSpec.configure do |config|
config.before(:each) do config.before(:each) do
allow_any_instance_of(PieceJustificativeUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f997") allow_any_instance_of(PieceJustificativeUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f997")
allow_any_instance_of(ProcedureLogoUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f998") allow_any_instance_of(ProcedureLogoUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f998")
allow_any_instance_of(CerfaUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f999")
end end
config.before(:all) { config.before(:all) {

View file

@ -2,8 +2,7 @@ require 'spec_helper'
describe 'users/description/show.html.haml', type: :view do describe 'users/description/show.html.haml', type: :view do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:cerfa_flag) { true } let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime) }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: cerfa_flag) }
let(:dossier) { create(:dossier, procedure: procedure, user: user) } let(:dossier) { create(:dossier, procedure: procedure, user: user) }
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
@ -21,14 +20,6 @@ describe 'users/description/show.html.haml', type: :view do
it 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do 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]") expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]")
end 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 end
context 'si la page précédente n\'est pas recapitulatif' do context 'si la page précédente n\'est pas recapitulatif' do
@ -102,17 +93,6 @@ describe 'users/description/show.html.haml', type: :view do
end 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 describe 'display title Documents administratifs' do
before do before do
render render
@ -121,7 +101,7 @@ describe 'users/description/show.html.haml', type: :view do
let(:procedure) { create :procedure, lien_demarche: '' } let(:procedure) { create :procedure, lien_demarche: '' }
let(:dossier) { create(:dossier, procedure: procedure) } let(:dossier) { create(:dossier, procedure: procedure) }
context 'when dossier not have cerfa, piece justificative and demarche link' do context 'when dossier not have piece justificative and demarche link' do
it { expect(rendered).not_to have_content 'Documents administratifs' } it { expect(rendered).not_to have_content 'Documents administratifs' }
end end
end end