Merge pull request #2819 from betagouv/fix_2818_forbid_empty_mandatory_field

[fix #2818] DossierController: ensure save_draft is authorized
This commit is contained in:
LeSim 2018-10-12 12:24:28 +02:00 committed by GitHub
commit af2250c21b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -264,7 +264,7 @@ module NewUser
end
def save_draft?
params[:save_draft]
dossier.brouillon? && params[:save_draft]
end
end
end

View file

@ -355,6 +355,13 @@ describe NewUser::DossiersController, type: :controller do
it { expect(response).to render_template(:brouillon) }
it { expect(flash.notice).to eq('Votre brouillon a bien été sauvegardé.') }
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:brouillon)) }
context 'and the dossier is in construction' do
let!(:dossier) { create(:dossier, :en_construction, user: user) }
it { expect(response).to render_template(:brouillon) }
it { expect(flash.alert).to eq(['Le champ l doit être rempli.', 'pj']) }
end
end
end