Save Champs value since description page
This commit is contained in:
parent
27dbd3a878
commit
6fbe735793
3 changed files with 29 additions and 1 deletions
|
@ -31,6 +31,11 @@ class Users::DescriptionController < UsersController
|
|||
cerfa.save
|
||||
end
|
||||
|
||||
@dossier.champs.each do |champ|
|
||||
champ.value = params[:champs]["'#{champ.id}'"]
|
||||
champ.save
|
||||
end
|
||||
|
||||
@dossier.pieces_justificatives.each do |piece_justificative|
|
||||
unless params["piece_justificative_#{piece_justificative.type}"].nil?
|
||||
piece_justificative.content = params["piece_justificative_#{piece_justificative.type}"]
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
= champ.libelle
|
||||
|
||||
-if champ.type_champs == 'textarea'
|
||||
%textarea.form-control{name:"champs[#{champ.id}]",
|
||||
%textarea.form-control{name:"champs['#{champ.id}']",
|
||||
placeholder: champ.libelle,
|
||||
id: "champs_#{champ.id}"}
|
||||
=champ.value
|
||||
|
|
|
@ -155,6 +155,29 @@ describe Users::DescriptionController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Sauvegarde des champs' do
|
||||
let(:champs_dossier) { dossier.champs }
|
||||
let(:dossier_champs_first) { 'test value' }
|
||||
before do
|
||||
post :create, {dossier_id: dossier_id,
|
||||
nom_projet: nom_projet,
|
||||
description: description,
|
||||
champs: {
|
||||
"'#{dossier.champs.first.id}'" => dossier_champs_first
|
||||
}
|
||||
}
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.champs.first.value).to eq(dossier_champs_first) }
|
||||
|
||||
context 'when champs value is empty' do
|
||||
let(:dossier_champs_first) { 'test value' }
|
||||
|
||||
it { expect(dossier.champs.first.value).to eq(dossier_champs_first) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'Sauvegarde des pièces justificatives' do
|
||||
let(:all_pj_type){ dossier.procedure.type_de_piece_justificative_ids }
|
||||
before do
|
||||
|
|
Loading…
Reference in a new issue