DossierController: allow upload of empty
This commit is contained in:
parent
b08eb3592b
commit
abc9068412
2 changed files with 13 additions and 2 deletions
|
@ -51,7 +51,7 @@ module NewUser
|
|||
|
||||
errors = PiecesJustificativesService.upload!(@dossier, current_user, params)
|
||||
|
||||
if !@dossier.update(champs_params)
|
||||
if champs_params[:dossier] && !@dossier.update(champs_params[:dossier])
|
||||
errors += @dossier.errors.full_messages
|
||||
end
|
||||
|
||||
|
@ -75,8 +75,9 @@ module NewUser
|
|||
|
||||
private
|
||||
|
||||
# FIXME: require(:dossier) when all the champs are united
|
||||
def champs_params
|
||||
params.require(:dossier).permit(champs_attributes: [:id, :value, :piece_justificative_file, value: []])
|
||||
params.permit(dossier: { champs_attributes: [:id, :value, :piece_justificative_file, value: []] })
|
||||
end
|
||||
|
||||
def dossier
|
||||
|
|
|
@ -212,5 +212,15 @@ describe NewUser::DossiersController, type: :controller do
|
|||
it { expect(dossier.reload.state).to eq('brouillon') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier has no champ' do
|
||||
let(:submit_payload) { { id: dossier.id } }
|
||||
|
||||
it 'does not raise any errors' do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to(users_dossier_recapitulatif_path(dossier))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue