Merge pull request #1493 from betagouv/empty_dossier

DossierController: allow upload of empty dossier
This commit is contained in:
LeSim 2018-02-27 17:43:52 +01:00 committed by GitHub
commit 2f030f6afe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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