Lors de la restauration d'une démarche supprimée, met sur les dossiers liés hidden_by_administration_at à nil
This commit is contained in:
parent
9c5bf1ed1f
commit
d58ecb3fcc
3 changed files with 11 additions and 3 deletions
|
@ -177,7 +177,7 @@ module Administrateurs
|
|||
|
||||
def restore
|
||||
procedure = current_administrateur.procedures.with_discarded.discarded.find(params[:id])
|
||||
procedure.restore_procedure
|
||||
procedure.restore_procedure(current_administrateur)
|
||||
flash.notice = t('administrateurs.index.restored', procedure_id: procedure.id)
|
||||
redirect_to admin_procedures_path
|
||||
end
|
||||
|
|
|
@ -707,9 +707,12 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def restore_procedure
|
||||
def restore_procedure(author)
|
||||
if discarded?
|
||||
undiscard
|
||||
self.dossiers.hidden_by_administration.each do |dossier|
|
||||
dossier.restore(author)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -785,7 +785,11 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'PUT #restore' do
|
||||
let(:procedure) { create :procedure, :discarded, administrateur: admin }
|
||||
let(:procedure) { create :procedure_with_dossiers, :with_service, :published, administrateur: admin }
|
||||
|
||||
before do
|
||||
procedure.discard_and_keep_track!(admin)
|
||||
end
|
||||
|
||||
context 'when the admin wants to restore a procedure' do
|
||||
before do
|
||||
|
@ -794,6 +798,7 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
it { expect(procedure.discarded?).to be_falsy }
|
||||
it { expect(procedure.dossiers.first.hidden_by_administration_at).to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue