fix(dossier): don't auto-number header sections in repetitions

This commit is contained in:
Colin Darie 2023-03-09 16:15:56 +01:00
parent 126819939b
commit f33d192142
2 changed files with 16 additions and 0 deletions

View file

@ -17,6 +17,8 @@ module DossierSectionsConcern
end
def auto_numbering_section_headers_for?(champ)
return false if champ.child?
sections_for(champ)&.none?(&:libelle_with_section_index?)
end

View file

@ -24,6 +24,20 @@ describe DossierSectionsConcern do
it { expect(dossier.auto_numbering_section_headers_for?(dossier.champs_public[1])).to eq(true) }
it { expect(dossier.auto_numbering_section_headers_for?(dossier.champs_private[1])).to eq(false) }
end
context "header_section in a repetition are not auto-numbered" do
let(:types_de_champ_public) { [{ type: :header_section, libelle: public_libelle }, { type: :repetition, mandatory: true, children: [{ type: :header_section, libelle: "Enfant" }, { type: :text }] }] }
context "with parent section having headers with number" do
let(:public_libelle) { "1. Infos" }
it { expect(dossier.auto_numbering_section_headers_for?(dossier.champs_public[1].rows[0][0])).to eq(false) }
end
context "with parent section having headers without number" do
let(:public_libelle) { "infos" }
it { expect(dossier.auto_numbering_section_headers_for?(dossier.champs_public[1].rows[0][0])).to eq(false) }
end
end
end
describe '#index_for_section_header' do