feat(type_de_champ_commune): add custom columns for iso export
feat(export.type): ensure right cast type on export Co-Authored-By: LeSim <mail@simon.lehericey.net
This commit is contained in:
parent
3b5acaad4c
commit
8792cb3cfd
3 changed files with 29 additions and 4 deletions
|
@ -27,6 +27,31 @@ class TypesDeChamp::CommuneTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
|||
champ.code_postal? ? "#{champ.name} (#{champ.code_postal})" : champ.name
|
||||
end
|
||||
|
||||
def columns(procedure:, displayable: true, prefix: nil)
|
||||
super.concat(
|
||||
[
|
||||
Columns::JSONPathColumn.new(
|
||||
procedure_id: procedure.id,
|
||||
stable_id:,
|
||||
tdc_type: type_champ,
|
||||
label: "#{libelle_with_prefix(prefix)} - code postal (5 chiffres)",
|
||||
jsonpath: '$.code_postal',
|
||||
displayable:,
|
||||
type: :text
|
||||
),
|
||||
Columns::JSONPathColumn.new(
|
||||
procedure_id: procedure.id,
|
||||
stable_id:,
|
||||
tdc_type: type_champ,
|
||||
label: "#{libelle_with_prefix(prefix)} - département",
|
||||
jsonpath: '$.code_departement',
|
||||
displayable:,
|
||||
type: :number
|
||||
)
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def paths
|
||||
|
|
|
@ -13,7 +13,7 @@ describe Columns::ChampColumn do
|
|||
expect_type_de_champ_values('email', eq(['yoda@beta.gouv.fr']))
|
||||
expect_type_de_champ_values('phone', eq(['0666666666']))
|
||||
expect_type_de_champ_values('address', eq(["2 rue des Démarches"]))
|
||||
expect_type_de_champ_values('communes', eq(["Coye-la-Forêt"]))
|
||||
expect_type_de_champ_values('communes', eq(["Coye-la-Forêt", "60580", "60"]))
|
||||
expect_type_de_champ_values('departements', eq(['01']))
|
||||
expect_type_de_champ_values('regions', eq(['01']))
|
||||
expect_type_de_champ_values('pays', eq(['France']))
|
||||
|
|
|
@ -52,13 +52,13 @@ describe ProcedureExportService do
|
|||
ExportedColumn.new(libelle: 'Groupe instructeur', column: procedure.find_column(label: 'Groupe instructeur')),
|
||||
ExportedColumn.new(libelle: 'État du dossier', column: procedure.dossier_state_column),
|
||||
ExportedColumn.new(libelle: 'first champ', column: procedure.find_column(label: 'first champ')),
|
||||
ExportedColumn.new(libelle: 'Commune (Code INSEE)', column: procedure.find_column(label: 'Commune (Code INSEE)')),
|
||||
ExportedColumn.new(libelle: 'Commune', column: procedure.find_column(label: 'Commune')),
|
||||
ExportedColumn.new(libelle: 'PJ', column: procedure.find_column(label: 'PJ'))
|
||||
]
|
||||
end
|
||||
|
||||
let!(:dossier) { create(:dossier, :en_instruction, :with_populated_champs, :with_individual, procedure: procedure) }
|
||||
let(:selected_headers) { ["Email", "first champ", "Commune (Code INSEE)", "Groupe instructeur", "Date du dernier évènement", "État du dossier", "PJ"] }
|
||||
let(:selected_headers) { ["Email", "first champ", "Commune", "Groupe instructeur", "Date du dernier évènement", "État du dossier", "PJ"] }
|
||||
|
||||
it 'should have only headers from export template' do
|
||||
expect(dossiers_sheet.headers).to match_array(selected_headers)
|
||||
|
@ -68,7 +68,7 @@ describe ProcedureExportService do
|
|||
expect(procedure.dossiers.count).to eq 1
|
||||
expect(dossiers_sheet.data.size).to eq 1
|
||||
|
||||
expect(dossiers_sheet.data).to match_array([[anything, dossier.user_email_for_display, "défaut", "En instruction", "text", "60172", "toto.txt"]])
|
||||
expect(dossiers_sheet.data).to match_array([[anything, dossier.user_email_for_display, "défaut", "En instruction", "text", "Coye-la-Forêt", "toto.txt"]])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue