fix(dossier): prevent users from removing mandatory fiels after submission
This commit is contained in:
parent
dc39de611d
commit
31d80d80bd
3 changed files with 27 additions and 2 deletions
|
@ -1 +1,2 @@
|
||||||
= render Attachment::EditComponent.new(form: form, attached_file: champ.piece_justificative_file, template: champ.type_de_champ.piece_justificative_template, user_can_destroy: true)
|
- user_can_destroy = !champ.mandatory? || champ.dossier.brouillon?
|
||||||
|
= render Attachment::EditComponent.new(form: form, attached_file: champ.piece_justificative_file, template: champ.type_de_champ.piece_justificative_template, user_can_destroy: user_can_destroy)
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
= render Attachment::EditComponent.new(form: form, attached_file: champ.piece_justificative_file, user_can_destroy: true)
|
- user_can_destroy = !champ.mandatory? || champ.dossier.brouillon?
|
||||||
|
= render Attachment::EditComponent.new(form: form, attached_file: champ.piece_justificative_file, user_can_destroy: user_can_destroy)
|
||||||
|
|
|
@ -103,6 +103,29 @@ describe 'shared/dossiers/edit.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with a mandatory piece justificative' do
|
||||||
|
let(:dossier) { create(:dossier) }
|
||||||
|
let(:type_de_champ) { create(:type_de_champ_piece_justificative, procedure: dossier.procedure, mandatory: true) }
|
||||||
|
let(:champ) { create(:champ_piece_justificative, dossier: dossier, type_de_champ: type_de_champ) }
|
||||||
|
|
||||||
|
context 'when dossier is en construction' do
|
||||||
|
let(:dossier) { create(:dossier, :en_construction) }
|
||||||
|
before { dossier.champs << champ }
|
||||||
|
|
||||||
|
it 'cannot delete a piece justificative' do
|
||||||
|
expect(subject).not_to have_text('Supprimer')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is brouillon' do
|
||||||
|
before { dossier.champs << champ }
|
||||||
|
|
||||||
|
it 'can delete a piece justificative' do
|
||||||
|
expect(subject).to have_text('Supprimer')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with a routed procedure' do
|
context 'with a routed procedure' do
|
||||||
let(:procedure) do
|
let(:procedure) do
|
||||||
create(:procedure,
|
create(:procedure,
|
||||||
|
|
Loading…
Reference in a new issue