Merge pull request #9550 from demarches-simplifiees/9542-reactivation-procedure
ETQ admin, je suis averti que je ne peux pas réactiver une démarche tant que la date limite de dépôt de dossiers n'est pas dans le futur
This commit is contained in:
commit
78058bc52a
2 changed files with 34 additions and 3 deletions
|
@ -264,10 +264,15 @@ module Administrateurs
|
|||
draft_revision: :types_de_champ
|
||||
).find(params[:procedure_id])
|
||||
|
||||
if @procedure.auto_archive_on && !@procedure.auto_archive_on.future?
|
||||
flash.alert = "La date limite de dépôt des dossiers doit être postérieure à la date du jour pour réactiver la procédure. #{view_context.link_to('Veuillez la modifier', edit_admin_procedure_path(@procedure))}"
|
||||
redirect_to admin_procedure_path(@procedure)
|
||||
else
|
||||
@procedure.path = @procedure.suggested_path(current_administrateur)
|
||||
@current_administrateur = current_administrateur
|
||||
@closed_procedures = current_administrateur.procedures.with_discarded.closes.map { |p| ["#{p.libelle} (#{p.id})", p.id] }.to_h
|
||||
end
|
||||
end
|
||||
|
||||
def publish
|
||||
@procedure.assign_attributes(publish_params)
|
||||
|
|
|
@ -902,6 +902,32 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GET #publication' do
|
||||
subject(:perform_request) { get :publication, params: { procedure_id: procedure.id } }
|
||||
|
||||
context 'when procedure is closed' do
|
||||
let(:procedure) { create(:procedure, :closed, administrateur: admin) }
|
||||
|
||||
it 'assigns procedure' do
|
||||
perform_request
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
|
||||
context 'with auto_archive on past' do
|
||||
before do
|
||||
procedure.auto_archive_on = Date.today - 1.week
|
||||
procedure.save(validate: false)
|
||||
end
|
||||
|
||||
it 'suggest to update autoarchive' do
|
||||
perform_request
|
||||
expect(response).to redirect_to(admin_procedure_path(procedure.id))
|
||||
expect(flash.alert).to include('La date limite de dépôt des dossiers doit être postérieure à la date du jour pour réactiver la procédure.')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #publish' do
|
||||
let(:procedure) { create(:procedure, administrateur: admin, lien_site_web: lien_site_web) }
|
||||
let(:procedure2) { create(:procedure, :published, administrateur: admin, lien_site_web: lien_site_web) }
|
||||
|
|
Loading…
Reference in a new issue