bug(type_de_champ.repetition): on repetition, when there is a TypeDeChamp::Commune, champs for export should contain 2 entries [one with commune (postal_code), the other for commune (code_insee)].

This commit is contained in:
Martin 2022-05-05 17:53:24 +02:00 committed by mfo
parent 9a350c4c05
commit b1340586de
2 changed files with 17 additions and 0 deletions

View file

@ -190,6 +190,12 @@ FactoryBot.define do
end
end
trait :with_repetition_commune do
after(:build) do |procedure, _evaluator|
build(:type_de_champ_repetition, types_de_champ: [build(:type_de_champ_communes)], procedure: procedure)
end
end
trait :with_number do
after(:build) do |procedure, _evaluator|
build(:type_de_champ_number, procedure: procedure)

View file

@ -1458,6 +1458,17 @@ describe Dossier do
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)
end
context 'within a repition having a type de champs commune (multiple values for export)' do
it 'works' do
proc_test = create(:procedure, :with_repetition_commune)
dossier_test = create(:dossier, procedure: proc_test)
repetition = proc_test.types_de_champ_for_procedure_presentation.repetition.first
type_champs = repetition.types_de_champ_for_revision(proc_test.active_revision).to_a
expect(type_champs.size).to eq(1)
expect(Dossier.champs_for_export(dossier.champs, type_champs).size).to eq(2)
end
end
end
context "when procedure brouillon" do