Merge pull request #4968 from tchak/clean-up-deleted-dossiers

Clean up deleted dossiers
This commit is contained in:
Paul Chavard 2020-03-31 17:06:34 +02:00 committed by GitHub
commit 89f1f70f0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 2 deletions

View file

@ -116,7 +116,7 @@ module Instructeurs
def deleted_dossiers
@procedure = procedure
@deleted_dossiers = @procedure
.deleted_dossiers.where.not(state: :brouillon)
.deleted_dossiers
.order(:dossier_id)
.page params[:page]
end

View file

@ -1,6 +1,8 @@
class DeletedDossier < ApplicationRecord
belongs_to :procedure
validates :dossier_id, uniqueness: true
enum reason: {
user_request: 'user_request',
manager_request: 'manager_request',

View file

@ -0,0 +1,10 @@
namespace :after_party do
desc 'Deployment task: cleanup_deleted_dossiers'
task cleanup_deleted_dossiers: :environment do
puts "Running deploy task 'cleanup_deleted_dossiers'"
DeletedDossier.where(state: :brouillon).destroy_all
AfterParty::TaskRecord.create version: '20200326133630'
end
end

View file

@ -413,7 +413,6 @@ describe Instructeurs::ProceduresController, type: :controller do
let(:instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure, instructeurs: [instructeur]) }
let(:deleted_dossier) { create(:deleted_dossier, procedure: procedure, state: :en_construction) }
let!(:deleted_dossier_brouillon) { create(:deleted_dossier, procedure: procedure, state: :brouillon) }
before do
sign_in(instructeur.user)