This commit is contained in:
Kara Diaby 2021-11-29 11:34:42 +01:00
parent 23677956f3
commit c75a9b6271
2 changed files with 42 additions and 7 deletions

View file

@ -160,20 +160,29 @@ describe Instructeurs::DossiersController, type: :controller do
let(:dossier) { create(:dossier, :refuse, procedure: procedure) }
let(:current_user) { instructeur.user }
before do
sign_in current_user
subject do
post :repasser_en_instruction,
params: { procedure_id: procedure.id, dossier_id: dossier.id },
format: 'js'
end
before do
sign_in current_user
end
context 'when the dossier is refuse' do
before { subject }
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('.header-actions') }
end
context 'when the dossier has already been put en_instruction' do
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
before { subject }
it 'warns about the error' do
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
expect(response).to have_http_status(:ok)
@ -184,11 +193,27 @@ describe Instructeurs::DossiersController, type: :controller do
context 'when the dossier is accepte' do
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
before { subject }
it 'it is possible to go back to en_instruction as instructeur' do
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
expect(response).to have_http_status(:ok)
end
end
context 'when the dossier is done and the user delete it' do
let!(:dossier) { create(:dossier, :accepte, procedure: procedure, user: current_user) }
before do
dossier.update!(hidden_by_user_at: Time.zone.now)
subject
end
it 'reveals the dossier' do
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
expect(dossier.reload.hidden_by_user_at).to be_nil
end
end
end
describe '#terminer' do

View file

@ -850,6 +850,16 @@ describe Users::DossiersController, type: :controller do
end
it { expect(assigns(:statut)).to eq('en-cours') }
end
context 'when the instructeur archive the dossier' do
before do
own_dossier2.update!(archived: true)
get(:index, params: { statut: 'en-cours' })
end
it { expect(assigns(:statut)).to eq('en-cours') }
it { expect(assigns(:dossiers_traites).map(&:id)).to eq([own_dossier2.id]) }
it { expect(own_dossier2.archived).to be_truthy }
end
end
describe 'sort order' do