Merge pull request #1493 from betagouv/empty_dossier
DossierController: allow upload of empty dossier
This commit is contained in:
commit
2f030f6afe
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