fix(dossier): fix rebasing submitted dossiers private champs type changes
This commit is contained in:
parent
0eceed4126
commit
ee1df3f05f
2 changed files with 15 additions and 4 deletions
|
@ -71,9 +71,7 @@ module DossierRebaseConcern
|
||||||
changes_by_op[:remove].each { champs_by_stable_id[_1.stable_id].destroy_all }
|
changes_by_op[:remove].each { champs_by_stable_id[_1.stable_id].destroy_all }
|
||||||
|
|
||||||
# update champ
|
# update champ
|
||||||
if brouillon?
|
changes_by_op[:update].each { apply(_1, champs_by_stable_id[_1.stable_id]) }
|
||||||
changes_by_op[:update].each { apply(_1, champs_by_stable_id[_1.stable_id]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
# due to repetition tdc clone on update or erase
|
# due to repetition tdc clone on update or erase
|
||||||
# we must reassign tdc to the latest version
|
# we must reassign tdc to the latest version
|
||||||
|
|
|
@ -261,7 +261,7 @@ describe DossierRebaseConcern do
|
||||||
{ type: :datetime, stable_id: 103 },
|
{ type: :datetime, stable_id: 103 },
|
||||||
{ type: :yes_no, stable_id: 104 },
|
{ type: :yes_no, stable_id: 104 },
|
||||||
{ type: :integer_number, stable_id: 105 }
|
{ type: :integer_number, stable_id: 105 }
|
||||||
])
|
], types_de_champ_private: [{ type: :text, stable_id: 11 }])
|
||||||
end
|
end
|
||||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||||
let(:types_de_champ) { procedure.active_revision.types_de_champ }
|
let(:types_de_champ) { procedure.active_revision.types_de_champ }
|
||||||
|
@ -283,6 +283,9 @@ describe DossierRebaseConcern do
|
||||||
|
|
||||||
let(:rebased_new_repetition_champ) { dossier.champs_public.find { _1.libelle == "une autre repetition" } }
|
let(:rebased_new_repetition_champ) { dossier.champs_public.find { _1.libelle == "une autre repetition" } }
|
||||||
|
|
||||||
|
let(:private_text_type_de_champ) { types_de_champ.find { _1.stable_id == 11 } }
|
||||||
|
let(:rebased_private_text_champ) { dossier.champs_private.find { _1.stable_id == 11 } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
procedure.publish!
|
procedure.publish!
|
||||||
procedure.draft_revision.add_type_de_champ({
|
procedure.draft_revision.add_type_de_champ({
|
||||||
|
@ -354,6 +357,16 @@ describe DossierRebaseConcern do
|
||||||
expect(rebased_new_repetition_champ.rebased_at).not_to be_nil
|
expect(rebased_new_repetition_champ.rebased_at).not_to be_nil
|
||||||
expect(rebased_new_repetition_champ.rows.size).to eq(1)
|
expect(rebased_new_repetition_champ.rows.size).to eq(1)
|
||||||
expect(rebased_new_repetition_champ.rows[0].size).to eq(2)
|
expect(rebased_new_repetition_champ.rows[0].size).to eq(2)
|
||||||
|
|
||||||
|
dossier.passer_en_construction!
|
||||||
|
procedure.draft_revision.find_and_ensure_exclusive_use(private_text_type_de_champ.stable_id).update(type_champ: TypeDeChamp.type_champs.fetch(:textarea))
|
||||||
|
procedure.publish_revision!
|
||||||
|
perform_enqueued_jobs
|
||||||
|
procedure.reload
|
||||||
|
dossier.reload
|
||||||
|
|
||||||
|
expect(rebased_private_text_champ.type_champ).to eq(TypeDeChamp.type_champs.fetch(:textarea))
|
||||||
|
expect(rebased_private_text_champ.type).to eq("Champs::TextareaChamp")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue