Merge pull request #4975 from tchak/remove-legacy-expiration-email

remove WarnExpiringDossiersJob
This commit is contained in:
Paul Chavard 2020-04-09 11:19:16 +02:00 committed by GitHub
commit c24f0b6b0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 0 additions and 125 deletions

View file

@ -1,11 +0,0 @@
class WarnExpiringDossiersJob < CronJob
self.schedule_expression = "every 1 month at midnight"
def perform(*args)
expiring, expired = Dossier
.en_instruction_close_to_expiration
.partition(&:retention_expired?)
AdministrationMailer.dossier_expiration_summary(expiring, expired).deliver_later
end
end

View file

@ -37,22 +37,4 @@ class AdministrationMailer < ApplicationMailer
mail(to: EQUIPE_EMAIL,
subject: subject)
end
def dossier_expiration_summary(expiring_dossiers, expired_dossiers)
subject =
if expired_dossiers.present? && expiring_dossiers.present?
"Des dossiers ont dépassé leur délai de conservation, et dautres en approchent"
elsif expired_dossiers.present?
"Des dossiers ont dépassé leur délai de conservation"
elsif expiring_dossiers.present?
"Des dossiers approchent de la fin de leur délai de conservation"
else
"Aucun dossier en fin de délai de conservation"
end
@expiring_dossiers = expiring_dossiers
@expired_dossiers = expired_dossiers
mail(to: TECH_EMAIL, subject: subject)
end
end

View file

@ -346,16 +346,6 @@ class Dossier < ApplicationRecord
!brouillon? && !archived
end
def retention_end_date
if instruction_commencee?
en_instruction_at + procedure.duree_conservation_dossiers_dans_ds.months
end
end
def retention_expired?
instruction_commencee? && retention_end_date <= Time.zone.now
end
def en_construction_close_to_expiration?
Dossier.en_construction_close_to_expiration.where(id: self).present?
end

View file

@ -1,28 +0,0 @@
- content_for(:title, 'Expiration du délai de conservation des dossiers')
- if @expired_dossiers.present?
%h2= t('mail.administration.dossier_expiration_summary.expired_dossiers', count: @expired_dossiers.count)
- @expired_dossiers.group_by(&:procedure).each do |procedure, dossiers|
%dl
%dt
- if procedure.present?
#{procedure.libelle} (#{link_to(procedure.id, manager_procedure_url(procedure))}) :
- else
Procédure supprimée
%dd
= dossiers.map { |d| link_to(d.id, manager_dossier_url(d)) }.join(', ').html_safe
- if @expiring_dossiers.present?
%h2= t('mail.administration.dossier_expiration_summary.expiring_dossiers', count: @expiring_dossiers.count)
- @expiring_dossiers.group_by(&:procedure).each do |procedure, dossiers|
%dl
%dt
- if procedure.present?
#{procedure.libelle} (#{link_to(procedure.id, manager_procedure_url(procedure))}) :
- else
Procédure supprimée
%dd
= dossiers.map { |d| link_to(d.id, manager_dossier_url(d)) }.join(', ').html_safe
- if @expired_dossiers.empty? && @expiring_dossiers.empty?
Il ny a pas de dossier expiré ou sur le point dexpirer.

View file

@ -33,36 +33,4 @@ RSpec.describe AdministrationMailer, type: :mailer do
it { expect(subject.subject).not_to be_empty }
end
describe '#dossier_expiration_summary' do
subject { described_class.dossier_expiration_summary(expiring, expired) }
context 'with expiring dossiers only' do
let(:expiring) { [create(:dossier)] }
let(:expired) { [] }
it { expect(subject.subject).to eq("Des dossiers approchent de la fin de leur délai de conservation") }
end
context 'with expired dossiers only' do
let(:expiring) { [] }
let(:expired) { [create(:dossier)] }
it { expect(subject.subject).to eq("Des dossiers ont dépassé leur délai de conservation") }
end
context 'with both expiring and expired dossiers' do
let(:expiring) { [create(:dossier)] }
let(:expired) { [create(:dossier)] }
it { expect(subject.subject).to eq("Des dossiers ont dépassé leur délai de conservation, et dautres en approchent") }
end
context 'with neither expiring nor expired dossiers' do
let(:expiring) { [] }
let(:expired) { [] }
it { expect(subject.subject).to eq("Aucun dossier en fin de délai de conservation") }
end
end
end

View file

@ -873,32 +873,6 @@ describe Dossier do
end
end
context "retention date" do
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 6) }
let(:uninstructed_dossier) { create(:dossier, :en_construction, procedure: procedure) }
let(:young_dossier) { create(:dossier, :en_instruction, en_instruction_at: Time.zone.now, procedure: procedure) }
let(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 6.months.ago, procedure: procedure) }
let(:long_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 1.year.ago, procedure: procedure) }
let(:modif_date) { Time.zone.parse('01/01/2100') }
before { Timecop.freeze(modif_date) }
after { Timecop.return }
describe "#retention_end_date" do
it { expect(uninstructed_dossier.retention_end_date).to be_nil }
it { expect(young_dossier.retention_end_date).to eq(6.months.from_now) }
it { expect(just_expired_dossier.retention_end_date).to eq(Time.zone.now) }
it { expect(long_expired_dossier.retention_end_date).to eq(6.months.ago) }
end
describe "#retention_expired?" do
it { expect(uninstructed_dossier).not_to be_retention_expired }
it { expect(young_dossier).not_to be_retention_expired }
it { expect(just_expired_dossier).to be_retention_expired }
it { expect(long_expired_dossier).to be_retention_expired }
end
end
describe '#accepter!' do
let(:dossier) { create(:dossier, :en_instruction) }
let(:last_operation) { dossier.dossier_operation_logs.last }