Merge pull request #7525 from tchak/feat-add-departement-info-to-commune-champ-export
feat(export): add déparctement info to commune champ export
This commit is contained in:
commit
2c8bdbf549
5 changed files with 18 additions and 6 deletions
|
@ -23,7 +23,7 @@ class Champs::CommuneChamp < Champs::TextChamp
|
||||||
store_accessor :value_json, :departement, :code_departement
|
store_accessor :value_json, :departement, :code_departement
|
||||||
|
|
||||||
def for_export
|
def for_export
|
||||||
[value, external_id]
|
[value, external_id, departement? ? departement_code_and_name : '']
|
||||||
end
|
end
|
||||||
|
|
||||||
def name_departement
|
def name_departement
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class TypesDeChamp::CommuneTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
class TypesDeChamp::CommuneTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
def libelle_for_export(index)
|
def libelle_for_export(index)
|
||||||
[libelle, "#{libelle} (Code insee)"][index]
|
[libelle, "#{libelle} (Code insee)", "#{libelle} (Département)"][index]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
describe Champs::CommuneChamp do
|
describe Champs::CommuneChamp do
|
||||||
let(:type_de_champ) { create(:type_de_champ_communes, libelle: 'Ma commune') }
|
let(:type_de_champ) { create(:type_de_champ_communes, libelle: 'Ma commune') }
|
||||||
let(:champ) { Champs::CommuneChamp.new(value: value, external_id: code_insee, type_de_champ: type_de_champ) }
|
let(:champ) { Champs::CommuneChamp.new(value: value, external_id: code_insee, departement: departement, code_departement: code_departement, type_de_champ: type_de_champ) }
|
||||||
let(:value) { 'Châteldon (63290)' }
|
let(:value) { 'Châteldon (63290)' }
|
||||||
let(:code_insee) { '63102' }
|
let(:code_insee) { '63102' }
|
||||||
|
let(:departement) { '' }
|
||||||
|
let(:code_departement) { '' }
|
||||||
|
|
||||||
it { expect(champ.value).to eq('Châteldon (63290)') }
|
it { expect(champ.value).to eq('Châteldon (63290)') }
|
||||||
it { expect(champ.external_id).to eq('63102') }
|
it { expect(champ.external_id).to eq('63102') }
|
||||||
it { expect(champ.for_export).to eq(['Châteldon (63290)', '63102']) }
|
it { expect(champ.for_export).to eq(['Châteldon (63290)', '63102', '']) }
|
||||||
|
|
||||||
|
context do
|
||||||
|
let(:departement) { 'Puy-de-Dôme' }
|
||||||
|
let(:code_departement) { '63' }
|
||||||
|
|
||||||
|
it { expect(champ.for_export).to eq(['Châteldon (63290)', '63102', '63 - Puy-de-Dôme']) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1464,7 +1464,7 @@ describe Dossier do
|
||||||
it "should have champs from all revisions" do
|
it "should have champs from all revisions" do
|
||||||
expect(dossier.types_de_champ.map(&:libelle)).to eq([text_type_de_champ.libelle, datetime_type_de_champ.libelle, "Yes/no", explication_type_de_champ.libelle, commune_type_de_champ.libelle, repetition_type_de_champ.libelle])
|
expect(dossier.types_de_champ.map(&:libelle)).to eq([text_type_de_champ.libelle, datetime_type_de_champ.libelle, "Yes/no", explication_type_de_champ.libelle, commune_type_de_champ.libelle, repetition_type_de_champ.libelle])
|
||||||
expect(dossier_second_revision.types_de_champ.map(&:libelle)).to eq([datetime_type_de_champ.libelle, "Updated yes/no", explication_type_de_champ.libelle, 'Commune de naissance', "Repetition", "New text field"])
|
expect(dossier_second_revision.types_de_champ.map(&:libelle)).to eq([datetime_type_de_champ.libelle, "Updated yes/no", explication_type_de_champ.libelle, 'Commune de naissance', "Repetition", "New text field"])
|
||||||
expect(dossier_champs_for_export.map { |(libelle)| libelle }).to eq([datetime_type_de_champ.libelle, text_type_de_champ.libelle, "Updated yes/no", "Commune de naissance", "Commune de naissance (Code insee)", "New text field"])
|
expect(dossier_champs_for_export.map { |(libelle)| libelle }).to eq([datetime_type_de_champ.libelle, text_type_de_champ.libelle, "Updated yes/no", "Commune de naissance", "Commune de naissance (Code insee)", "Commune de naissance (Département)", "New text field"])
|
||||||
expect(dossier_champs_for_export).to eq(dossier_second_revision_champs_for_export)
|
expect(dossier_champs_for_export).to eq(dossier_second_revision_champs_for_export)
|
||||||
expect(repetition_second_revision_champs_for_export.map { |(libelle)| libelle }).to eq(procedure.types_de_champ_for_procedure_presentation.repetition.map(&:libelle_for_export))
|
expect(repetition_second_revision_champs_for_export.map { |(libelle)| libelle }).to eq(procedure.types_de_champ_for_procedure_presentation.repetition.map(&:libelle_for_export))
|
||||||
expect(repetition_second_revision_champs_for_export.first.size).to eq(2)
|
expect(repetition_second_revision_champs_for_export.first.size).to eq(2)
|
||||||
|
@ -1483,7 +1483,7 @@ describe Dossier do
|
||||||
repetition = proc_test.types_de_champ_for_procedure_presentation.repetition.first
|
repetition = proc_test.types_de_champ_for_procedure_presentation.repetition.first
|
||||||
type_champs = proc_test.types_de_champ_for_procedure_presentation(repetition).to_a
|
type_champs = proc_test.types_de_champ_for_procedure_presentation(repetition).to_a
|
||||||
expect(type_champs.size).to eq(1)
|
expect(type_champs.size).to eq(1)
|
||||||
expect(Dossier.champs_for_export(dossier.champs, type_champs).size).to eq(2)
|
expect(Dossier.champs_for_export(dossier.champs, type_champs).size).to eq(3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,6 +69,7 @@ describe ProcedureExportService do
|
||||||
"departements",
|
"departements",
|
||||||
"communes",
|
"communes",
|
||||||
"communes (Code insee)",
|
"communes (Code insee)",
|
||||||
|
"communes (Département)",
|
||||||
"engagement",
|
"engagement",
|
||||||
"dossier_link",
|
"dossier_link",
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
|
@ -160,6 +161,7 @@ describe ProcedureExportService do
|
||||||
"departements",
|
"departements",
|
||||||
"communes",
|
"communes",
|
||||||
"communes (Code insee)",
|
"communes (Code insee)",
|
||||||
|
"communes (Département)",
|
||||||
"engagement",
|
"engagement",
|
||||||
"dossier_link",
|
"dossier_link",
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
|
@ -245,6 +247,7 @@ describe ProcedureExportService do
|
||||||
"departements",
|
"departements",
|
||||||
"communes",
|
"communes",
|
||||||
"communes (Code insee)",
|
"communes (Code insee)",
|
||||||
|
"communes (Département)",
|
||||||
"engagement",
|
"engagement",
|
||||||
"dossier_link",
|
"dossier_link",
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
|
|
Loading…
Reference in a new issue