implement turbostream back for state change in dossier view

This commit is contained in:
Lisa Durand 2023-02-24 15:48:29 +01:00
parent b03748d3dd
commit 6487e2c27e
8 changed files with 64 additions and 36 deletions

View file

@ -153,16 +153,16 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
it { expect(instructeur.follow?(dossier)).to be true }
it { expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure)) }
it { expect(flash.notice).to eq("Dossier passé en instruction.") }
it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.sub-header') }
context 'when the dossier has already been put en_instruction' do
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
it 'warns about the error' do
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure))
expect(flash.alert).to eq("Le dossier est déjà en instruction.")
expect(response).to have_http_status(:ok)
expect(response.body).to include('Le dossier est déjà en instruction.')
end
end
@ -174,8 +174,8 @@ describe Instructeurs::DossiersController, type: :controller do
end
it 'warns about the error' do
expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure))
expect(flash.alert).to eq("Le dossier est en ce moment accepté : il nest pas possible de le passer en instruction.")
expect(response).to have_http_status(:ok)
expect(response.body).to include('Le dossier est en ce moment accepté : il nest pas possible de le passer en instruction.')
end
end
@ -199,16 +199,16 @@ describe Instructeurs::DossiersController, type: :controller do
end
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) }
it { expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure)) }
it { expect(flash.notice).to eq("Dossier repassé en construction.") }
it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.sub-header') }
context 'when the dossier has already been put en_construction' do
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
it 'warns about the error' do
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure))
expect(flash.alert).to eq("Le dossier est déjà en construction.")
expect(response).to have_http_status(:ok)
expect(response.body).to include('Le dossier est déjà en construction.')
end
end
@ -235,8 +235,8 @@ describe Instructeurs::DossiersController, type: :controller do
context 'when the dossier is refuse' do
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
it { expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure)) }
it { expect(flash.notice).to eq("Le dossier #{dossier.id} a été repassé en instruction.") }
it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.sub-header') }
end
context 'when the dossier has already been put en_instruction' do
@ -244,8 +244,8 @@ describe Instructeurs::DossiersController, type: :controller do
it 'warns about the error' do
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction))
expect(response).to redirect_to(instructeur_procedure_path(dossier.procedure))
expect(flash.alert).to eq("Le dossier est déjà en instruction.")
expect(response).to have_http_status(:ok)
expect(response.body).to include('Le dossier est déjà en instruction.')
end
end
@ -254,8 +254,7 @@ describe Instructeurs::DossiersController, type: :controller do
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 redirect_to(instructeur_procedure_path(dossier.procedure))
expect(flash.notice).to eq("Le dossier #{dossier.id} a été repassé en instruction.")
expect(response).to have_http_status(:ok)
end
end
@ -314,7 +313,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached
end
it { expect(subject.body).to include('.header-actions') }
it { expect(subject.body).to include('.sub-header') }
end
context 'with dossier in batch_operation' do
@ -354,7 +353,7 @@ describe Instructeurs::DossiersController, type: :controller do
subject
end
it { expect(subject.body).to include('.header-actions') }
it { expect(subject.body).to include('.sub-header') }
end
context 'with attachment' do
@ -368,7 +367,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached
end
it { expect(subject.body).to include('.header-actions') }
it { expect(subject.body).to include('.sub-header') }
end
end
@ -410,14 +409,14 @@ describe Instructeurs::DossiersController, type: :controller do
end
it 'The instructeur is sent back to the dossier page' do
expect(subject.body).to include('.header-actions')
expect(subject.body).to include('.sub-header')
end
context 'and the dossier has already an attestation' do
it 'should not crash' do
dossier.attestation = Attestation.new
dossier.save
expect(subject.body).to include('.header-actions')
expect(subject.body).to include('.sub-header')
end
end
end
@ -456,7 +455,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached
end
it { expect(subject.body).to include('.header-actions') }
it { expect(subject.body).to include('.sub-header') }
end
end

View file

@ -39,7 +39,9 @@ describe 'Instructing a dossier:', js: true do
click_on 'Passer en instruction'
expect(page).to have_text('en instruction')
expect(page).to have_text('Dossier passé en instruction.')
expect(page).to have_text('Instruire le dossier')
expect(page).to have_selector('.label.en-instruction')
dossier.reload
expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction))