[fix #2818] DossierController: ensure save_draft is authorized

This commit is contained in:
simon lehericey 2018-10-12 12:11:43 +02:00
parent 8fd2c95ea2
commit 888bbee097
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