Merge pull request #10992 from demarches-simplifiees/align-column-naming-and-prepare-columns-for-export

WIP – tech: ETQ instructeur, amélioration du nommage des colonnes pour les filtres/display/export. préparation du nommage des colonnes a exporter
This commit is contained in:
mfo 2024-10-31 06:13:38 +00:00 committed by GitHub
commit 11d4465bf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 352 additions and 105 deletions

View file

@ -25,49 +25,49 @@ module ColumnsConcern
columns.concat(standard_columns) columns.concat(standard_columns)
columns.concat(individual_columns) if for_individual columns.concat(individual_columns) if for_individual
columns.concat(moral_columns) if !for_individual columns.concat(moral_columns) if !for_individual
columns.concat(procedure_chorus_columns) if chorusable? && chorus_configuration.complete?
columns.concat(types_de_champ_columns) columns.concat(types_de_champ_columns)
end end
end end
def dossier_id_column def usager_columns_for_export
Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'id', type: :number) columns = [dossier_id_column, user_email_for_display_column, user_france_connected_column]
columns.concat(individual_columns) if for_individual
columns.concat(moral_columns) if !for_individual
columns.concat(procedure_chorus_columns) if chorusable? && chorus_configuration.complete?
# ensure the columns exist in main list
columns.filter { _1.id.in?(self.columns.map(&:id)) }
end end
def dossier_state_column def dossier_columns_for_export
Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) columns = [dossier_state_column, dossier_archived_column]
columns.concat(dossier_dates_columns)
columns.concat([dossier_motivation_column])
columns.concat(sva_svr_columns(for_export: true)) if sva_svr_enabled?
columns.concat([groupe_instructeurs_id_column, followers_instructeurs_email_column])
# ensure the columns exist in main list
columns.filter { _1.id.in?(self.columns.map(&:id)) }
end end
def notifications_column def dossier_id_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'id', type: :number)
Columns::DossierColumn.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false)
end
def dossier_columns def dossier_state_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false)
common = [dossier_id_column, notifications_column]
dates = ['created_at', 'updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at'] def notifications_column = Columns::DossierColumn.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false)
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date) }
non_displayable_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since']
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) }
states = [dossier_state_column]
[common, dates, sva_svr_columns, non_displayable_dates, states].flatten.compact
end
def sva_svr_columns
return if !sva_svr_enabled?
def sva_svr_columns(for_export: false)
scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self] scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self]
columns = [ columns = [
Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_on', type: :date, Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_on', type: :date,
label: I18n.t("#{sva_svr_decision}_decision_on", scope:)) label: I18n.t("#{sva_svr_decision}_decision_on", scope:, type: sva_svr_configuration.human_decision))
] ]
if !for_export
columns << Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false, columns << Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false,
label: I18n.t("#{sva_svr_decision}_decision_before", scope:)) label: I18n.t("#{sva_svr_decision}_decision_before", scope:))
end
columns columns
end end
@ -79,32 +79,75 @@ module ColumnsConcern
private private
def groupe_instructeurs_id_column = Columns::DossierColumn.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum)
def followers_instructeurs_email_column = Columns::DossierColumn.new(procedure_id: id, table: 'followers_instructeurs', column: 'email')
def dossier_archived_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false);
def dossier_motivation_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'motivation', type: :text, displayable: false, filterable: false);
def user_email_for_display_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false)
def user_france_connected_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false)
def procedure_chorus_columns
['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout']
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) }
end
def dossier_non_displayable_dates_columns
['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since']
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) }
end
def dossier_dates_columns
['created_at', 'updated_at', 'last_champ_updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at']
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date) }
end
def email_column def email_column
Columns::DossierColumn.new(procedure_id: id, table: 'user', column: 'email') Columns::DossierColumn.new(procedure_id: id, table: 'user', column: 'email')
end end
def dossier_columns
columns = [dossier_id_column, notifications_column]
columns.concat([dossier_state_column])
columns.concat([dossier_archived_column])
columns.concat(dossier_dates_columns)
columns.concat([dossier_motivation_column])
columns.concat(sva_svr_columns(for_export: false)) if sva_svr_enabled?
columns.concat(dossier_non_displayable_dates_columns)
end
def standard_columns def standard_columns
[ [
email_column, email_column,
Columns::DossierColumn.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'), user_email_for_display_column,
Columns::DossierColumn.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum), followers_instructeurs_email_column,
Columns::DossierColumn.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false) # not filterable ? groupe_instructeurs_id_column,
Columns::DossierColumn.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false),
user_france_connected_column
] ]
end end
def individual_columns def individual_columns
['nom', 'prenom', 'gender'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'individual', column:) } ['gender', 'nom', 'prenom'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'individual', column:) }
.concat ['for_tiers', 'mandataire_last_name', 'mandataire_first_name'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:) }
end end
def moral_columns def moral_columns
etablissements = ['entreprise_siren', 'entreprise_forme_juridique', 'entreprise_nom_commercial', 'entreprise_raison_sociale', 'entreprise_siret_siege_social'] etablissements = ['entreprise_forme_juridique', 'entreprise_siren', 'entreprise_nom_commercial', 'entreprise_raison_sociale', 'entreprise_siret_siege_social']
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) } .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) }
etablissement_dates = ['entreprise_date_creation'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:, type: :date) } etablissement_dates = ['entreprise_date_creation'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:, type: :date) }
for_export = ["siege_social", "naf", "adresse", "numero_voie", "type_voie", "nom_voie", "complement_adresse", "localite", "code_insee_localite", "entreprise_siren", "entreprise_capital_social", "entreprise_numero_tva_intracommunautaire", "entreprise_forme_juridique_code", "entreprise_code_effectif_entreprise", "entreprise_etat_administratif", "entreprise_nom", "entreprise_prenom", "association_rna", "association_titre", "association_objet", "association_date_creation", "association_date_declaration", "association_date_publication"]
.map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:, displayable: false, filterable: false) }
other = ['siret', 'libelle_naf', 'code_postal'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) } other = ['siret', 'libelle_naf', 'code_postal'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) }
[etablissements, etablissement_dates, other].flatten [etablissements, etablissement_dates, other, for_export].flatten
end end
def types_de_champ_columns def types_de_champ_columns

View file

@ -450,6 +450,10 @@ class Dossier < ApplicationRecord
end end
end end
def user_email_for_display
user_email_for(:display)
end
def expiration_started? def expiration_started?
[ [
brouillon_close_to_expiration_notice_sent_at, brouillon_close_to_expiration_notice_sent_at,

View file

@ -34,12 +34,13 @@ class ProcedurePresentation < ApplicationRecord
def filters_name_for(statut) = statut.tr('-', '_').then { "#{_1}_filters" } def filters_name_for(statut) = statut.tr('-', '_').then { "#{_1}_filters" }
def displayed_fields_for_headers def displayed_fields_for_headers
[ columns = [
procedure.dossier_id_column, procedure.dossier_id_column,
*displayed_columns, *displayed_columns,
procedure.dossier_state_column, procedure.dossier_state_column
*procedure.sva_svr_columns
] ]
columns.concat(procedure.sva_svr_columns) if procedure.sva_svr_enabled?
columns
end end
def human_value_for_filter(filtered_column) def human_value_for_filter(filtered_column)

View file

@ -5,24 +5,34 @@ en:
fields: fields:
self: self:
id: File  id: File 
user_email_for_display: Email
state: State state: State
created_at: Created on created_at: Created on
updated_at: Updated on updated_at: Updated on
depose_at: First submission on depose_at: First submission on
en_construction_at: Submitted on en_construction_at: Submitted on
en_instruction_at: En instruction on en_instruction_at: Instructed on
processed_at: Done on processed_at: Done on
depose_since: First Submission since depose_since: First Submission since
updated_since: Updated since updated_since: Updated since
en_construction_since: Submitted since en_construction_since: Submitted since
en_instruction_since: Instructed since en_instruction_since: Instructed since
processed_since: Finished since processed_since: Finished since
sva_decision_on: SVA decision date sva_decision_on: Date décision %{type}
sva_decision_before: SVA decision date before sva_decision_before: SVA decision date before
svr_decision_on: SVR decision date svr_decision_on: Date décision %{type}
svr_decision_before: SVR decision date before svr_decision_before: SVR decision date before
user_from_france_connect?: "France connecté ?"
for_tiers: "For tiers"
mandataire_last_name: "Tier last name"
mandataire_first_name: "Tier first name"
user: user:
id: User Id
email: Requester email: Requester
procedure:
domaine_fonctionnel: Domaine Fonctionnel
referentiel_prog: Référentiel De Programmation
centre_de_cout: Centre De Coût
followers_instructeurs: followers_instructeurs:
email: Email instructeur email: Email instructeur
groupe_instructeur: groupe_instructeur:
@ -36,12 +46,38 @@ en:
answer: Opinion answer: Opinion
question_answer: Opinion yes/no question_answer: Opinion yes/no
etablissement: etablissement:
entreprise_siren: SIREN entreprise_etat_administratif: 'Entreprise état administratif'
entreprise_forme_juridique: Forme juridique entreprise_forme_juridique: Forme juridique
entreprise_nom_commercial: Commercial name entreprise_nom_commercial: Commercial name
entreprise_raison_sociale: Raison sociale entreprise_raison_sociale: Raison sociale
entreprise_siret_siege_social: SIRET siège social entreprise_siret_siege_social: SIRET siège social
entreprise_date_creation: Creation date entreprise_date_creation: Entreprise date de création
siret: SIRET siret: Établissement SIRET
libelle_naf: Libellé NAF libelle_naf: Libellé NAF
code_postal: Postal code siege_social: "Établissement siège social"
naf: "Établissement NAF"
adresse: "Établissement Adresse"
numero_voie: "Établissement numero voie"
type_voie: "Établissement type voie"
nom_voie: "Établissement nom voie"
complement_adresse: "Établissement complément adresse"
code_postal: "Établissement code postal"
localite: "Établissement localité"
code_insee_localite: "Établissement code INSEE localité"
entreprise_siren: SIREN
entreprise_capital_social: "Entreprise capital social"
entreprise_numero_tva_intracommunautaire: "Entreprise numero TVA intracommunautaire"
entreprise_forme_juridique: "Entreprise forme juridique"
entreprise_forme_juridique_code: "Entreprise forme juridique code"
entreprise_nom_commercial: "Entreprise nom commercial"
entreprise_raison_sociale: "Entreprise raison sociale"
entreprise_siret_siege_social: "Entreprise SIRET siège social"
entreprise_code_effectif_entreprise: "Entreprise code effectif entreprise"
entreprise_nom: 'Entreprise nom'
entreprise_prenom: 'Entreprise prénom'
association_rna: 'Association RNA'
association_titre: 'Association titre'
association_objet: 'Association objet'
association_date_creation: 'Association date de création'
association_date_declaration: 'Association date de déclaration'
association_date_publication: 'Association date de publication'

View file

@ -5,26 +5,40 @@ fr:
fields: fields:
self: self:
id:  dossier id:  dossier
state: Statut user_email_for_display: Email
created_at: Créé le state: État du dossier
updated_at: Mis à jour le created_at: Date de création
depose_at: Déposé le updated_at: Date du dernier évènement
en_construction_at: En construction le depose_at: Date de dépot
en_instruction_at: En instruction le en_construction_at: Date de passage en construction
processed_at: Terminé le en_instruction_at: Date de passage en instruction
updated_since: Mis à jour depuis processed_at: Date de traitement
updated_since: Dernier évènement depuis
depose_since: Déposé depuis depose_since: Déposé depuis
en_construction_since: En construction depuis en_construction_since: En construction depuis
en_instruction_since: En instruction depuis en_instruction_since: En instruction depuis
processed_since: Terminé depuis processed_since: Traité depuis
sva_decision_on: Date décision SVA sva_decision_on: Date décision %{type}
sva_decision_before: Date décision SVA avant sva_decision_before: Date décision SVA avant
svr_decision_on: Date décision SVR svr_decision_on: Date décision %{type}
svr_decision_before: Date décision SVR avant svr_decision_before: Date décision SVR avant
user_from_france_connect?: "France connecté ?"
for_tiers: "Dépôt pour un tiers"
mandataire_last_name: "Nom du mandataire"
mandataire_first_name: "Prénom du mandataire"
archived: 'Archivé'
dossier_state: 'État du dossier'
last_champ_updated_at: Date de dernière modification (usager)
motivation: 'Motivation de la décision'
user: user:
id: Identifiant du demandeur
email: Demandeur email: Demandeur
procedure:
domaine_fonctionnel: Domaine Fonctionnel
referentiel_prog: Référentiel De Programmation
centre_de_cout: Centre De Coût
followers_instructeurs: followers_instructeurs:
email: Email instructeur email: Instructeurs
groupe_instructeur: groupe_instructeur:
id: Groupe instructeur id: Groupe instructeur
label: Groupe instructeur label: Groupe instructeur
@ -36,12 +50,38 @@ fr:
answer: Avis answer: Avis
question_answer: Avis oui/non question_answer: Avis oui/non
etablissement: etablissement:
entreprise_siren: SIREN entreprise_etat_administratif: 'Entreprise état administratif'
entreprise_forme_juridique: Forme juridique entreprise_forme_juridique: Forme juridique
entreprise_nom_commercial: Nom commercial entreprise_nom_commercial: Nom commercial
entreprise_raison_sociale: Raison sociale entreprise_raison_sociale: Raison sociale
entreprise_siret_siege_social: SIRET siège social entreprise_siret_siege_social: SIRET siège social
entreprise_date_creation: Date de création entreprise_date_creation: Entreprise date de création
siret: SIRET siret: Établissement SIRET
libelle_naf: Libellé NAF libelle_naf: Libellé NAF
code_postal: Code postal siege_social: "Établissement siège social"
naf: "Établissement NAF"
adresse: "Établissement Adresse"
numero_voie: "Établissement numero voie"
type_voie: "Établissement type voie"
nom_voie: "Établissement nom voie"
complement_adresse: "Établissement complément adresse"
code_postal: "Établissement code postal"
localite: "Établissement localité"
code_insee_localite: "Établissement code INSEE localité"
entreprise_siren: "Entreprise SIREN"
entreprise_capital_social: "Entreprise capital social"
entreprise_numero_tva_intracommunautaire: "Entreprise numero TVA intracommunautaire"
entreprise_forme_juridique: "Entreprise forme juridique"
entreprise_forme_juridique_code: "Entreprise forme juridique code"
entreprise_nom_commercial: "Entreprise nom commercial"
entreprise_raison_sociale: "Entreprise raison sociale"
entreprise_siret_siege_social: "Entreprise SIRET siège social"
entreprise_code_effectif_entreprise: "Entreprise code effectif entreprise"
entreprise_nom: 'Entreprise nom'
entreprise_prenom: 'Entreprise prénom'
association_rna: 'Association RNA'
association_titre: 'Association titre'
association_objet: 'Association objet'
association_date_creation: 'Association date de création'
association_date_declaration: 'Association date de déclaration'
association_date_publication: 'Association date de publication'

View file

@ -38,7 +38,7 @@ describe '20240920130741_migrate_procedure_presentation_to_columns.rake' do
it 'populates the columns' do it 'populates the columns' do
procedure_id = procedure.id procedure_id = procedure.id
expect(procedure_presentation.displayed_columns.map(&:label)).to eq(["Raison sociale", procedure.active_revision.types_de_champ.first.libelle]) expect(procedure_presentation.displayed_columns.map(&:label)).to eq(["Entreprise raison sociale", procedure.active_revision.types_de_champ.first.libelle])
order, column_id = procedure_presentation order, column_id = procedure_presentation
.sorted_column .sorted_column

View file

@ -29,24 +29,28 @@ describe ColumnsConcern do
let(:tdc_private_2) { procedure.active_revision.types_de_champ_private[1] } let(:tdc_private_2) { procedure.active_revision.types_de_champ_private[1] }
let(:expected) { let(:expected) {
[ [
{ label: ' dossier', table: 'self', column: 'id', displayable: true, type: :number, scope: '', value_column: :value, filterable: true }, { label: 'Dossier ID', table: 'self', column: 'id', displayable: true, type: :number, scope: '', value_column: :value, filterable: true },
{ label: 'notifications', table: 'notifications', column: 'notifications', displayable: true, type: :text, scope: '', value_column: :value, filterable: false }, { label: 'notifications', table: 'notifications', column: 'notifications', displayable: true, type: :text, scope: '', value_column: :value, filterable: false },
{ label: 'Créé le', table: 'self', column: 'created_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'Date de création', table: 'self', column: 'created_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true },
{ label: 'Mis à jour le', table: 'self', column: 'updated_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'Mis à jour le', table: 'self', column: 'updated_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true },
{ label: 'Déposé le', table: 'self', column: 'depose_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'Date de dépot', table: 'self', column: 'depose_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true },
{ label: 'En construction le', table: 'self', column: 'en_construction_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'En construction le', table: 'self', column: 'en_construction_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true },
{ label: 'En instruction le', table: 'self', column: 'en_instruction_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'En instruction le', table: 'self', column: 'en_instruction_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true },
{ label: 'Terminé le', table: 'self', column: 'processed_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'Terminé le', table: 'self', column: 'processed_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true },
{ label: "Mis à jour depuis", table: "self", column: "updated_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "Dernier évènement depuis", table: "self", column: "updated_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true },
{ label: "Déposé depuis", table: "self", column: "depose_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "Déposé depuis", table: "self", column: "depose_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true },
{ label: "En construction depuis", table: "self", column: "en_construction_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "En construction depuis", table: "self", column: "en_construction_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true },
{ label: "En instruction depuis", table: "self", column: "en_instruction_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "En instruction depuis", table: "self", column: "en_instruction_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true },
{ label: "Terminé depuis", table: "self", column: "processed_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "Traité depuis", table: "self", column: "processed_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true },
{ label: "Statut", table: "self", column: "state", displayable: false, scope: 'instructeurs.dossiers.filterable_state', type: :enum, value_column: :value, filterable: true }, { label: "Statut", table: "self", column: "state", displayable: false, scope: 'instructeurs.dossiers.filterable_state', type: :enum, value_column: :value, filterable: true },
{ label: "Archivé", table: "self", column: "archived", displayable: false, scope: '', type: :text, value_column: :value, filterable: false },
{ label: "Motivation de la décision", table: "self", column: "motivation", displayable: false, scope: '', type: :text, value_column: :value, filterable: false },
{ label: "Date de dernière modification (usager)", table: "self", column: "last_champ_updated_at", displayable: false, scope: '', type: :text, value_column: :value, filterable: false },
{ label: 'Demandeur', table: 'user', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Demandeur', table: 'user', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
{ label: 'Email instructeur', table: 'followers_instructeurs', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Email instructeur', table: 'followers_instructeurs', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
{ label: 'Groupe instructeur', table: 'groupe_instructeur', column: 'id', displayable: true, type: :enum, scope: '', value_column: :value, filterable: true }, { label: 'Groupe instructeur', table: 'groupe_instructeur', column: 'id', displayable: true, type: :enum, scope: '', value_column: :value, filterable: true },
{ label: 'Avis oui/non', table: 'avis', column: 'question_answer', displayable: true, type: :text, scope: '', value_column: :value, filterable: false }, { label: 'Avis oui/non', table: 'avis', column: 'question_answer', displayable: true, type: :text, scope: '', value_column: :value, filterable: false },
{ label: 'France connecté ?', table: 'self', column: 'user_from_france_connect?', displayable: false, type: :text, scope: '', value_column: :value, filterable: false },
{ label: 'SIREN', table: 'etablissement', column: 'entreprise_siren', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'SIREN', table: 'etablissement', column: 'entreprise_siren', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
{ label: 'Forme juridique', table: 'etablissement', column: 'entreprise_forme_juridique', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Forme juridique', table: 'etablissement', column: 'entreprise_forme_juridique', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
{ label: 'Nom commercial', table: 'etablissement', column: 'entreprise_nom_commercial', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Nom commercial', table: 'etablissement', column: 'entreprise_nom_commercial', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
@ -73,7 +77,11 @@ describe ColumnsConcern do
procedure.active_revision.types_de_champ_private[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication)) procedure.active_revision.types_de_champ_private[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication))
end end
it { expect(subject).to eq(expected) } it {
expected.each do |expected|
expect(subject).to include(expected)
end
}
end end
context 'with rna' do context 'with rna' do
@ -125,4 +133,119 @@ describe ColumnsConcern do
it { is_expected.to include(decision_on, decision_before_field) } it { is_expected.to include(decision_on, decision_before_field) }
end end
end end
describe 'export' do
let(:procedure) { create(:procedure_with_dossiers, :published, types_de_champ_public:, for_individual:) }
let(:for_individual) { true }
let(:types_de_champ_public) do
[
{ type: :text, libelle: "Ca va ?", mandatory: true, stable_id: 1 },
{ type: :communes, libelle: "Commune", mandatory: true, stable_id: 17 },
{ type: :siret, libelle: 'siret', stable_id: 20 },
{ type: :repetition, mandatory: true, stable_id: 7, libelle: "Champ répétable", children: [{ type: 'text', libelle: 'Qqchose à rajouter?', stable_id: 8 }] }
]
end
describe '#usager_columns_for_export' do
context 'for individual procedure' do
let(:for_individual) { true }
it "returns all usager columns" do
expected = [
procedure.find_column(label: " dossier"),
procedure.find_column(label: "Email"),
procedure.find_column(label: "France connecté ?"),
procedure.find_column(label: "Civilité"),
procedure.find_column(label: "Nom"),
procedure.find_column(label: "Prénom"),
procedure.find_column(label: "Dépôt pour un tiers"),
procedure.find_column(label: "Nom du mandataire"),
procedure.find_column(label: "Prénom du mandataire")
]
actuals = procedure.usager_columns_for_export.map(&:h_id)
expected.each do |expected_col|
expect(actuals).to include(expected_col.h_id)
end
end
end
context 'for entreprise procedure' do
let(:for_individual) { false }
it "returns all usager columns" do
expected = [
procedure.find_column(label: " dossier"),
procedure.find_column(label: "Email"),
procedure.find_column(label: "France connecté ?"),
procedure.find_column(label: "Établissement SIRET"),
procedure.find_column(label: "Établissement siège social"),
procedure.find_column(label: "Établissement NAF"),
procedure.find_column(label: "Libellé NAF"),
procedure.find_column(label: "Établissement Adresse"),
procedure.find_column(label: "Établissement numero voie"),
procedure.find_column(label: "Établissement type voie"),
procedure.find_column(label: "Établissement nom voie"),
procedure.find_column(label: "Établissement complément adresse"),
procedure.find_column(label: "Établissement code postal"),
procedure.find_column(label: "Établissement localité"),
procedure.find_column(label: "Établissement code INSEE localité"),
procedure.find_column(label: "Entreprise SIREN"),
procedure.find_column(label: "Entreprise capital social"),
procedure.find_column(label: "Entreprise numero TVA intracommunautaire"),
procedure.find_column(label: "Entreprise forme juridique"),
procedure.find_column(label: "Entreprise forme juridique code"),
procedure.find_column(label: "Entreprise nom commercial"),
procedure.find_column(label: "Entreprise raison sociale"),
procedure.find_column(label: "Entreprise SIRET siège social"),
procedure.find_column(label: "Entreprise code effectif entreprise")
]
actuals = procedure.usager_columns_for_export
expected.each do |expected_col|
expect(actuals.map(&:h_id)).to include(expected_col.h_id)
end
expect(actuals.any? { _1.label == "Nom" }).to eq false
end
end
context 'when procedure chorusable' do
let(:procedure) { create(:procedure_with_dossiers, :filled_chorus, types_de_champ_public:) }
it 'returns specific chorus columns' do
allow_any_instance_of(Procedure).to receive(:chorusable?).and_return(true)
expected = [
procedure.find_column(label: "Domaine Fonctionnel"),
procedure.find_column(label: "Référentiel De Programmation"),
procedure.find_column(label: "Centre De Coût")
]
actuals = procedure.usager_columns_for_export.map(&:h_id)
expected.each do |expected_col|
expect(actuals).to include(expected_col.h_id)
end
end
end
end
describe '#dossier_columns_for_export' do
let(:procedure) { create(:procedure_with_dossiers, :routee, :published, types_de_champ_public:, for_individual:) }
it "returns all dossier columns" do
expected = [
procedure.find_column(label: "Archivé"),
procedure.find_column(label: "État du dossier"),
procedure.find_column(label: "Date du dernier évènement"),
procedure.find_column(label: "Date de dernière modification (usager)"),
procedure.find_column(label: "Date de dépot"),
procedure.find_column(label: "Date de passage en instruction"),
procedure.find_column(label: "Date de traitement"),
procedure.find_column(label: "Motivation de la décision"),
procedure.find_column(label: "Instructeurs"),
procedure.find_column(label: "Groupe instructeur")
]
actuals = procedure.dossier_columns_for_export.map(&:h_id)
expected.each do |expected_col|
expect(actuals).to include(expected_col.h_id)
end
end
end
end
end end

View file

@ -81,7 +81,7 @@ RSpec.describe Export, type: :model do
let(:instructeur) { create(:instructeur) } let(:instructeur) { create(:instructeur) }
let!(:gi_1) { create(:groupe_instructeur, procedure: procedure, instructeurs: [instructeur]) } let!(:gi_1) { create(:groupe_instructeur, procedure: procedure, instructeurs: [instructeur]) }
let!(:pp) { gi_1.instructeurs.first.procedure_presentation_and_errors_for_procedure_id(procedure.id).first } let!(:pp) { gi_1.instructeurs.first.procedure_presentation_and_errors_for_procedure_id(procedure.id).first }
let(:created_at_column) { FilteredColumn.new(column: procedure.find_column(label: 'Créé le'), filter: '10/12/2021') } let(:created_at_column) { FilteredColumn.new(column: procedure.find_column(label: 'Date de création'), filter: '10/12/2021') }
before { pp.update(tous_filters: [created_at_column]) } before { pp.update(tous_filters: [created_at_column]) }
@ -95,7 +95,7 @@ RSpec.describe Export, type: :model do
expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) } expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) }
.to change { Export.count }.by(1) .to change { Export.count }.by(1)
update_at_column = FilteredColumn.new(column: procedure.find_column(label: 'Mis à jour le'), filter: '10/12/2021') update_at_column = FilteredColumn.new(column: procedure.find_column(label: 'Date du dernier évènement'), filter: '10/12/2021')
pp.update(tous_filters: [created_at_column, update_at_column]) pp.update(tous_filters: [created_at_column, update_at_column])
expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) } expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) }
@ -181,7 +181,7 @@ RSpec.describe Export, type: :model do
let(:statut) { 'tous' } let(:statut) { 'tous' }
let(:procedure_presentation) do let(:procedure_presentation) do
statut_column = procedure.find_column(label: 'Statut') statut_column = procedure.dossier_state_column
en_construction_filter = FilteredColumn.new(column: statut_column, filter: 'en_construction') en_construction_filter = FilteredColumn.new(column: statut_column, filter: 'en_construction')
create(:procedure_presentation, create(:procedure_presentation,
procedure:, procedure:,

View file

@ -77,7 +77,7 @@ describe ProcedurePresentation do
end end
context 'when filter is state' do context 'when filter is state' do
let(:filtered_column) { to_filter(['Statut', "en_construction"]) } let(:filtered_column) { to_filter(['État du dossier', "en_construction"]) }
it 'should get i18n value' do it 'should get i18n value' do
expect(subject).to eq("En construction") expect(subject).to eq("En construction")
@ -85,7 +85,7 @@ describe ProcedurePresentation do
end end
context 'when filter is a date' do context 'when filter is a date' do
let(:filtered_column) { to_filter(['Créé le', "15/06/2023"]) } let(:filtered_column) { to_filter(['Date de création', "15/06/2023"]) }
it 'should get formatted value' do it 'should get formatted value' do
expect(subject).to eq("15/06/2023") expect(subject).to eq("15/06/2023")
@ -94,8 +94,8 @@ describe ProcedurePresentation do
end end
describe '#update_displayed_fields' do describe '#update_displayed_fields' do
let(:en_construction_column) { procedure.find_column(label: 'En construction le') } let(:en_construction_column) { procedure.find_column(label: 'Date de passage en construction') }
let(:mise_a_jour_column) { procedure.find_column(label: 'Mis à jour le') } let(:mise_a_jour_column) { procedure.find_column(label: 'Date du dernier évènement') }
let(:procedure_presentation) do let(:procedure_presentation) do
create(:procedure_presentation, assign_to:).tap do |pp| create(:procedure_presentation, assign_to:).tap do |pp|

View file

@ -41,7 +41,7 @@ describe DossierFilterService do
context 'when a filter is present' do context 'when a filter is present' do
let(:filtered_ids) { [dossier_1, dossier_2, dossier_3].map(&:id) } let(:filtered_ids) { [dossier_1, dossier_2, dossier_3].map(&:id) }
let(:filters) { [to_filter(['Statut', 'en_construction'])] } let(:filters) { [to_filter(['État du dossier', 'en_construction'])] }
before do before do
expect(described_class).to receive(:filtered_ids).and_return(filtered_ids) expect(described_class).to receive(:filtered_ids).and_return(filtered_ids)
@ -102,7 +102,7 @@ describe DossierFilterService do
let(:order) { 'asc' } # Desc works the same, no extra test required let(:order) { 'asc' } # Desc works the same, no extra test required
context 'for created_at column' do context 'for created_at column' do
let!(:column) { procedure.find_column(label: 'Créé le') } let!(:column) { procedure.find_column(label: 'Date de création') }
let!(:recent_dossier) { Timecop.freeze(Time.zone.local(2018, 10, 17)) { create(:dossier, procedure:) } } let!(:recent_dossier) { Timecop.freeze(Time.zone.local(2018, 10, 17)) { create(:dossier, procedure:) } }
let!(:older_dossier) { Timecop.freeze(Time.zone.local(2003, 11, 11)) { create(:dossier, procedure:) } } let!(:older_dossier) { Timecop.freeze(Time.zone.local(2003, 11, 11)) { create(:dossier, procedure:) } }
@ -110,7 +110,7 @@ describe DossierFilterService do
end end
context 'for en_construction_at column' do context 'for en_construction_at column' do
let!(:column) { procedure.find_column(label: 'En construction le') } let!(:column) { procedure.find_column(label: 'Date de passage en construction') }
let!(:recent_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:recent_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) }
let!(:older_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) } let!(:older_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) }
@ -118,7 +118,7 @@ describe DossierFilterService do
end end
context 'for updated_at column' do context 'for updated_at column' do
let(:column) { procedure.find_column(label: 'Mis à jour le') } let(:column) { procedure.find_column(label: 'Date du dernier évènement') }
let(:recent_dossier) { create(:dossier, procedure:) } let(:recent_dossier) { create(:dossier, procedure:) }
let(:older_dossier) { create(:dossier, procedure:) } let(:older_dossier) { create(:dossier, procedure:) }
@ -251,7 +251,7 @@ describe DossierFilterService do
end end
context 'for email column' do context 'for email column' do
let(:column) { procedure.find_column(label: 'Email instructeur') } let(:column) { procedure.find_column(label: 'Instructeurs') }
it { is_expected.to eq([dossier_a, dossier_z, dossier_without_instructeur].map(&:id)) } it { is_expected.to eq([dossier_a, dossier_z, dossier_without_instructeur].map(&:id)) }
end end
@ -275,7 +275,7 @@ describe DossierFilterService do
context 'for other tables' do context 'for other tables' do
# All other columns and tables work the same so its ok to test only one # All other columns and tables work the same so its ok to test only one
let(:column) { procedure.find_column(label: 'Code postal') } let(:column) { procedure.find_column(label: 'Établissement code postal') }
let(:order) { 'asc' } # Desc works the same, no extra test required let(:order) { 'asc' } # Desc works the same, no extra test required
let!(:huitieme_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75008')) } let!(:huitieme_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75008')) }
@ -297,7 +297,7 @@ describe DossierFilterService do
context 'for self table' do context 'for self table' do
context 'for created_at column' do context 'for created_at column' do
let(:filter) { ['Créé le', '18/9/2018'] } let(:filter) { ['Date de création', '18/9/2018'] }
let!(:kept_dossier) { create(:dossier, procedure:, created_at: Time.zone.local(2018, 9, 18, 14, 28)) } let!(:kept_dossier) { create(:dossier, procedure:, created_at: Time.zone.local(2018, 9, 18, 14, 28)) }
let!(:discarded_dossier) { create(:dossier, procedure:, created_at: Time.zone.local(2018, 9, 17, 23, 59)) } let!(:discarded_dossier) { create(:dossier, procedure:, created_at: Time.zone.local(2018, 9, 17, 23, 59)) }
@ -306,7 +306,7 @@ describe DossierFilterService do
end end
context 'for en_construction_at column' do context 'for en_construction_at column' do
let(:filter) { ['En construction le', '17/10/2018'] } let(:filter) { ['Date de passage en construction', '17/10/2018'] }
let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) }
let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) } let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) }
@ -315,7 +315,7 @@ describe DossierFilterService do
end end
context 'for updated_at column' do context 'for updated_at column' do
let(:filter) { ['Mis à jour le', '18/9/2018'] } let(:filter) { ['Date du dernier évènement', '18/9/2018'] }
let(:kept_dossier) { create(:dossier, procedure:) } let(:kept_dossier) { create(:dossier, procedure:) }
let(:discarded_dossier) { create(:dossier, procedure:) } let(:discarded_dossier) { create(:dossier, procedure:) }
@ -329,7 +329,7 @@ describe DossierFilterService do
end end
context 'for updated_since column' do context 'for updated_since column' do
let(:filter) { ['Mis à jour depuis', '18/9/2018'] } let(:filter) { ['Dernier évènement depuis', '18/9/2018'] }
let(:kept_dossier) { create(:dossier, procedure:) } let(:kept_dossier) { create(:dossier, procedure:) }
let(:later_dossier) { create(:dossier, procedure:) } let(:later_dossier) { create(:dossier, procedure:) }
@ -362,7 +362,7 @@ describe DossierFilterService do
end end
context 'ignore time of day' do context 'ignore time of day' do
let(:filter) { ['En construction le', '17/10/2018 19:30'] } let(:filter) { ['Date de passage en construction', '17/10/2018 19:30'] }
let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17, 15, 56)) } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17, 15, 56)) }
let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 18, 5, 42)) } let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 18, 5, 42)) }
@ -372,20 +372,20 @@ describe DossierFilterService do
context 'for a malformed date' do context 'for a malformed date' do
context 'when its a string' do context 'when its a string' do
let(:filter) { ['Mis à jour le', 'malformed date'] } let(:filter) { ['Date du dernier évènement', 'malformed date'] }
it { is_expected.to match([]) } it { is_expected.to match([]) }
end end
context 'when its a number' do context 'when its a number' do
let(:filter) { ['Mis à jour le', '177500'] } let(:filter) { ['Date du dernier évènement', '177500'] }
it { is_expected.to match([]) } it { is_expected.to match([]) }
end end
end end
context 'with multiple search values' do context 'with multiple search values' do
let(:filters) { [['En construction le', '17/10/2018'], ['En construction le', '19/10/2018']] } let(:filters) { [['Date de passage en construction', '17/10/2018'], ['Date de passage en construction', '19/10/2018']] }
let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) }
let!(:other_kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 19)) } let!(:other_kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 19)) }
@ -397,7 +397,7 @@ describe DossierFilterService do
end end
context 'with multiple state filters' do context 'with multiple state filters' do
let(:filters) { [['Statut', 'en_construction'], ['Statut', 'en_instruction']] } let(:filters) { [['État du dossier', 'en_construction'], ['État du dossier', 'en_instruction']] }
let!(:kept_dossier) { create(:dossier, :en_construction, procedure:) } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:) }
let!(:other_kept_dossier) { create(:dossier, :en_instruction, procedure:) } let!(:other_kept_dossier) { create(:dossier, :en_instruction, procedure:) }
@ -409,7 +409,7 @@ describe DossierFilterService do
end end
context 'with en_construction state filters' do context 'with en_construction state filters' do
let(:filter) { ['Statut', 'en_construction'] } let(:filter) { ['État du dossier', 'en_construction'] }
let!(:en_construction) { create(:dossier, :en_construction, procedure:) } let!(:en_construction) { create(:dossier, :en_construction, procedure:) }
let!(:en_construction_with_correction) { create(:dossier, :en_construction, procedure:) } let!(:en_construction_with_correction) { create(:dossier, :en_construction, procedure:) }
@ -580,7 +580,7 @@ describe DossierFilterService do
context 'for etablissement table' do context 'for etablissement table' do
context 'for entreprise_date_creation column' do context 'for entreprise_date_creation column' do
let(:filter) { ['Date de création', '21/6/2018'] } let(:filter) { ['Entreprise date de création', '21/6/2018'] }
let!(:kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2018, 6, 21))) } let!(:kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2018, 6, 21))) }
let!(:discarded_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2008, 6, 21))) } let!(:discarded_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2008, 6, 21))) }
@ -588,7 +588,7 @@ describe DossierFilterService do
it { is_expected.to contain_exactly(kept_dossier.id) } it { is_expected.to contain_exactly(kept_dossier.id) }
context 'with multiple search values' do context 'with multiple search values' do
let(:filters) { [['Date de création', '21/6/2016'], ['Date de création', '21/6/2018']] } let(:filters) { [['Entreprise date de création', '21/6/2016'], ['Entreprise date de création', '21/6/2018']] }
let!(:other_kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2016, 6, 21))) } let!(:other_kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2016, 6, 21))) }
@ -601,7 +601,7 @@ describe DossierFilterService do
context 'for code_postal column' do context 'for code_postal column' do
# All columns except entreprise_date_creation work exacly the same, just testing one # All columns except entreprise_date_creation work exacly the same, just testing one
let(:filter) { ['Code postal', '75017'] } let(:filter) { ['Établissement code postal', '75017'] }
let!(:kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75017')) } let!(:kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75017')) }
let!(:discarded_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '25000')) } let!(:discarded_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '25000')) }
@ -609,7 +609,7 @@ describe DossierFilterService do
it { is_expected.to contain_exactly(kept_dossier.id) } it { is_expected.to contain_exactly(kept_dossier.id) }
context 'with multiple search values' do context 'with multiple search values' do
let(:filters) { [['Code postal', '75017'], ['Code postal', '88100']] } let(:filters) { [['Établissement code postal', '75017'], ['Établissement code postal', '88100']] }
let!(:other_kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '88100')) } let!(:other_kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '88100')) }
@ -674,7 +674,7 @@ describe DossierFilterService do
end end
context 'for followers_instructeurs table' do context 'for followers_instructeurs table' do
let(:filter) { ['Email instructeur', 'keepmail'] } let(:filter) { ['Instructeurs', 'keepmail'] }
let!(:kept_dossier) { create(:dossier, procedure:) } let!(:kept_dossier) { create(:dossier, procedure:) }
let!(:discarded_dossier) { create(:dossier, procedure:) } let!(:discarded_dossier) { create(:dossier, procedure:) }
@ -687,7 +687,7 @@ describe DossierFilterService do
it { is_expected.to contain_exactly(kept_dossier.id) } it { is_expected.to contain_exactly(kept_dossier.id) }
context 'with multiple search values' do context 'with multiple search values' do
let(:filters) { [['Email instructeur', 'keepmail'], ['Email instructeur', 'beta.gouv.fr']] } let(:filters) { [['Instructeurs', 'keepmail'], ['Instructeurs', 'beta.gouv.fr']] }
let(:other_kept_dossier) { create(:dossier, procedure:) } let(:other_kept_dossier) { create(:dossier, procedure:) }

View file

@ -80,28 +80,28 @@ describe DossierProjectionService do
context 'for self table' do context 'for self table' do
context 'for created_at column' do context 'for created_at column' do
let(:label) { 'Créé le' } let(:label) { 'Date de création' }
let(:dossier) { Timecop.freeze(Time.zone.local(1992, 3, 22)) { create(:dossier, procedure:) } } let(:dossier) { Timecop.freeze(Time.zone.local(1992, 3, 22)) { create(:dossier, procedure:) } }
it { is_expected.to eq('22/03/1992') } it { is_expected.to eq('22/03/1992') }
end end
context 'for en_construction_at column' do context 'for en_construction_at column' do
let(:label) { 'En construction le' } let(:label) { 'Date de passage en construction' }
let(:dossier) { create(:dossier, :en_construction, en_construction_at: Time.zone.local(2018, 10, 17), procedure:) } let(:dossier) { create(:dossier, :en_construction, en_construction_at: Time.zone.local(2018, 10, 17), procedure:) }
it { is_expected.to eq('17/10/2018') } it { is_expected.to eq('17/10/2018') }
end end
context 'for depose_at column' do context 'for depose_at column' do
let(:label) { 'Déposé le' } let(:label) { 'Date de dépot' }
let(:dossier) { create(:dossier, :en_construction, depose_at: Time.zone.local(2018, 10, 17), procedure:) } let(:dossier) { create(:dossier, :en_construction, depose_at: Time.zone.local(2018, 10, 17), procedure:) }
it { is_expected.to eq('17/10/2018') } it { is_expected.to eq('17/10/2018') }
end end
context 'for updated_at column' do context 'for updated_at column' do
let(:label) { 'Mis à jour le' } let(:label) { 'Date du dernier évènement' }
let(:dossier) { create(:dossier, procedure:) } let(:dossier) { create(:dossier, procedure:) }
before { dossier.touch(time: Time.zone.local(2018, 9, 25)) } before { dossier.touch(time: Time.zone.local(2018, 9, 25)) }
@ -142,7 +142,7 @@ describe DossierProjectionService do
end end
context 'for etablissement table' do context 'for etablissement table' do
let(:label) { 'Code postal' } let(:label) { 'Établissement code postal' }
let!(:dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75008')) } let!(:dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75008')) }
@ -158,7 +158,7 @@ describe DossierProjectionService do
end end
context 'for followers_instructeurs table' do context 'for followers_instructeurs table' do
let(:label) { 'Email instructeur' } let(:label) { 'Instructeurs' }
let(:dossier) { create(:dossier, procedure:) } let(:dossier) { create(:dossier, procedure:) }
let!(:follow1) { create(:follow, dossier: dossier, instructeur: create(:instructeur, email: 'b@host.fr')) } let!(:follow1) { create(:follow, dossier: dossier, instructeur: create(:instructeur, email: 'b@host.fr')) }

View file

@ -44,9 +44,9 @@ describe "procedure filters" do
end end
scenario "should add be able to add created_at column", js: true do scenario "should add be able to add created_at column", js: true do
add_column("Créé le") add_column("Date de création")
within ".dossiers-table" do within ".dossiers-table" do
expect(page).to have_link("Créé le") expect(page).to have_link("Date de création")
expect(page).to have_link(new_unfollow_dossier.created_at.strftime('%d/%m/%Y')) expect(page).to have_link(new_unfollow_dossier.created_at.strftime('%d/%m/%Y'))
end end
end end
@ -99,10 +99,10 @@ describe "procedure filters" do
scenario "should be able to user custom fiters", js: true do scenario "should be able to user custom fiters", js: true do
# use date filter # use date filter
add_filter("En construction le", "10/10/2010", type: :date) add_filter("Date de passage en construction", "10/10/2010", type: :date)
# use statut dropdown filter # use statut dropdown filter
add_filter('Statut', 'En construction', type: :enum) add_filter('État du dossier', 'En construction', type: :enum)
# use choice dropdown filter # use choice dropdown filter
add_filter('Choix unique', 'val1', type: :enum) add_filter('Choix unique', 'val1', type: :enum)