refactor(dossier): flatten champ attributes

This commit is contained in:
Paul Chavard 2022-11-29 11:30:06 +01:00
parent 4ef06217b2
commit 1b95809f14
12 changed files with 61 additions and 80 deletions

View file

@ -599,12 +599,12 @@ describe Champ do
context "when has parent" do
let(:champ) { create(:champ_text, parent: create(:champ_text)) }
it { expect(champ.input_name).to eq "dossier[champs_public_attributes][#{champ.parent_id}][champs_attributes][#{champ.id}]" }
it { expect(champ.input_name).to eq "dossier[champs_public_attributes][#{champ.id}]" }
end
context "when has private parent" do
let(:champ) { create(:champ_text, private: true, parent: create(:champ_text, private: true)) }
it { expect(champ.input_name).to eq "dossier[champs_private_attributes][#{champ.parent_id}][champs_attributes][#{champ.id}]" }
it { expect(champ.input_name).to eq "dossier[champs_private_attributes][#{champ.id}]" }
end
end
end

View file

@ -26,8 +26,16 @@ describe DossierPreloader do
expect(first_child.type).to eq('Champs::TextChamp')
expect(repetition.id).not_to eq(first_child.id)
expect(subject.champs.first.dossier).to eq(subject)
expect(subject.champs_public_all.first.dossier).to eq(subject)
expect(subject.champs_public.first.dossier).to eq(subject)
expect(subject.champs_public.first.type_de_champ.piece_justificative_template.attached?).to eq(false)
expect(subject.champs.first.conditional?).to eq(false)
expect(subject.champs_public_all.first.conditional?).to eq(false)
expect(subject.champs_public.first.conditional?).to eq(false)
expect(first_child.parent).to eq(repetition)
end