feat(instructeurs/dossier): explicit error about impossible transition due to incomplete etablissement
This commit is contained in:
parent
e7de19b24d
commit
fe2b3ec936
2 changed files with 20 additions and 0 deletions
|
@ -308,6 +308,8 @@ module Instructeurs
|
|||
def aasm_error_message(exception, target_state:)
|
||||
if exception.originating_state == target_state
|
||||
"Le dossier est déjà #{dossier_display_state(target_state, lower: true)}."
|
||||
elsif exception.failures.include?(:can_terminer?)
|
||||
"Les données relatives au SIRET de ce dossier n’ont pas pu encore être vérifiées : il n’est pas possible de le passer #{dossier_display_state(target_state, lower: true)}."
|
||||
else
|
||||
"Le dossier est en ce moment #{dossier_display_state(exception.originating_state, lower: true)} : il n’est pas possible de le passer #{dossier_display_state(target_state, lower: true)}."
|
||||
end
|
||||
|
|
|
@ -388,6 +388,24 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when related etablissement is still in degraded_mode' do
|
||||
let(:procedure) { create(:procedure, :published, for_individual: false, instructeurs: instructeurs) }
|
||||
let(:dossier) { create(:dossier, :en_instruction, :with_entreprise, procedure: procedure, as_degraded_mode: true) }
|
||||
|
||||
subject { post :terminer, params: { process_action: "accepter", procedure_id: procedure.id, dossier_id: dossier.id }, format: :turbo_stream }
|
||||
|
||||
context "with accepter" do
|
||||
it 'warns about the error' do
|
||||
subject
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to match(/Les données relatives au SIRET .+ de le passer accepté/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a dossier is already closed' do
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue