Same for go back in instruction
This commit is contained in:
parent
5f39d3eac8
commit
768a298c2d
2 changed files with 30 additions and 2 deletions
|
@ -103,8 +103,12 @@ module Gestionnaires
|
||||||
end
|
end
|
||||||
|
|
||||||
def repasser_en_instruction
|
def repasser_en_instruction
|
||||||
flash.notice = "Le dossier #{dossier.id} a été repassé en instruction."
|
if dossier.en_instruction?
|
||||||
dossier.repasser_en_instruction!(current_gestionnaire)
|
flash.notice = 'Le dossier est déjà en instruction.'
|
||||||
|
else
|
||||||
|
flash.notice = "Le dossier #{dossier.id} a été repassé en instruction."
|
||||||
|
dossier.repasser_en_instruction!(current_gestionnaire)
|
||||||
|
end
|
||||||
|
|
||||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||||
end
|
end
|
||||||
|
|
|
@ -151,6 +151,30 @@ describe Gestionnaires::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#repasser_en_instruction' do
|
||||||
|
let(:dossier) { create(:dossier, :refuse, procedure: procedure) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in gestionnaire
|
||||||
|
post :repasser_en_instruction,
|
||||||
|
params: { procedure_id: procedure.id, dossier_id: dossier.id },
|
||||||
|
format: 'js'
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||||
|
it { expect(response).to have_http_status(:ok) }
|
||||||
|
it { expect(response.body).to include('.state-button') }
|
||||||
|
|
||||||
|
context 'when the dossier has already been put en_instruction' do
|
||||||
|
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||||
|
|
||||||
|
it 'warns about the error, but doesn’t raise' do
|
||||||
|
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#terminer' do
|
describe '#terminer' do
|
||||||
context "with refuser" do
|
context "with refuser" do
|
||||||
before do
|
before do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue