Merge pull request #3825 from betagouv/dev

2019-04-29-01
This commit is contained in:
Pierre de La Morinerie 2019-04-29 17:04:37 +02:00 committed by GitHub
commit 3d8cd40f1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View file

@ -1,8 +1,6 @@
require Rails.root.join('lib', 'percentile')
class Procedure < ApplicationRecord
self.ignored_columns = [:administrateur_id]
MAX_DUREE_CONSERVATION = 36
has_many :types_de_piece_justificative, -> { ordered }, dependent: :destroy

View file

@ -0,0 +1,19 @@
namespace :after_party do
desc 'Deployment task: add_procedure_administrateur_to_administrateurs_for_hidden_procedures'
task add_procedure_administrateur_to_administrateurs_for_hidden_procedures: :environment do
rake_puts "Running deploy task: 'add_procedure_administrateur_to_administrateurs_for_hidden_procedures'"
hidden_procedures = Procedure.unscoped.hidden.includes(:administrateurs)
progress = ProgressReport.new(hidden_procedures.count)
hidden_procedures.find_each do |procedure|
deprecated_administrateur = Administrateur.find_by(id: procedure.administrateur_id)
if deprecated_administrateur && !procedure.administrateurs.include?(deprecated_administrateur)
procedure.administrateurs << deprecated_administrateur
end
progress.inc
end
progress.finish
AfterParty::TaskRecord.create version: '20190429103024'
end
end

View file

@ -31,7 +31,7 @@ describe Dossier do
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 6) }
let!(:young_dossier) { create(:dossier, procedure: procedure) }
let!(:expiring_dossier) { create(:dossier, :en_instruction, en_instruction_at: 170.days.ago, procedure: procedure) }
let!(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: (6.months + 1.second).ago, procedure: procedure) }
let!(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: (6.months + 1.hour + 1.second).ago, procedure: procedure) }
let!(:long_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 1.year.ago, procedure: procedure) }
context 'with default delay to end of retention' do