fix(dossier): don't auto-number header sections in repetitions
This commit is contained in:
parent
126819939b
commit
f33d192142
2 changed files with 16 additions and 0 deletions
|
@ -17,6 +17,8 @@ module DossierSectionsConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def auto_numbering_section_headers_for?(champ)
|
def auto_numbering_section_headers_for?(champ)
|
||||||
|
return false if champ.child?
|
||||||
|
|
||||||
sections_for(champ)&.none?(&:libelle_with_section_index?)
|
sections_for(champ)&.none?(&:libelle_with_section_index?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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_public[1])).to eq(true) }
|
||||||
it { expect(dossier.auto_numbering_section_headers_for?(dossier.champs_private[1])).to eq(false) }
|
it { expect(dossier.auto_numbering_section_headers_for?(dossier.champs_private[1])).to eq(false) }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe '#index_for_section_header' do
|
describe '#index_for_section_header' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue