fix(Users::Dossiers#brouillon): should only be accessible for having brouillon state

This commit is contained in:
mfo 2025-01-06 14:07:11 +01:00
parent 7932be7d96
commit 4ceadc3d28
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
2 changed files with 12 additions and 0 deletions

View file

@ -16,6 +16,7 @@ module Users
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_siret, :brouillon, :submit_brouillon, :submit_en_construction, :modifier, :update, :champ]
before_action :ensure_dossier_can_be_filled, only: [:brouillon, :modifier, :submit_brouillon, :submit_en_construction, :update]
before_action :ensure_dossier_can_be_viewed, only: [:show]
before_action :ensure_editing_brouillon, only: [:brouillon]
before_action :forbid_closed_submission!, only: [:submit_brouillon]
before_action :set_dossier_as_editing_fork, only: [:submit_en_construction]
before_action :show_demarche_en_test_banner
@ -461,6 +462,12 @@ module Users
end
end
def ensure_editing_brouillon
if !dossier.brouillon?
redirect_to modifier_dossier_path(@dossier)
end
end
def page
[params[:page].to_i, 1].max
end

View file

@ -371,6 +371,11 @@ describe Users::DossiersController, type: :controller do
it { is_expected.to redirect_to(identite_dossier_path(dossier)) }
end
end
context 'when the dossier is en_construction' do
let!(:dossier) { create(:dossier, :en_construction, user: user, autorisation_donnees: true) }
it { is_expected.to redirect_to(modifier_dossier_path(dossier)) }
end
end
describe '#edit' do