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:
commit
af2250c21b
2 changed files with 8 additions and 1 deletions
|
@ -264,7 +264,7 @@ module NewUser
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_draft?
|
def save_draft?
|
||||||
params[:save_draft]
|
dossier.brouillon? && params[:save_draft]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -355,6 +355,13 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
it { expect(response).to render_template(:brouillon) }
|
it { expect(response).to render_template(:brouillon) }
|
||||||
it { expect(flash.notice).to eq('Votre brouillon a bien été sauvegardé.') }
|
it { expect(flash.notice).to eq('Votre brouillon a bien été sauvegardé.') }
|
||||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:brouillon)) }
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue