From eb3b928cf2942baa2b000e98f0a6405bd5a3bdb0 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Wed, 17 Jul 2024 15:42:26 +0200 Subject: [PATCH] change scope to include new column for expiring dossiers --- app/models/dossier.rb | 7 ++++--- spec/jobs/cron/discarded_dossiers_deletion_job_spec.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 0c5a74939..0201c14d2 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -367,9 +367,10 @@ class Dossier < ApplicationRecord scope :without_termine_expiration_notice_sent, -> { where(termine_close_to_expiration_notice_sent_at: nil) } scope :deleted_by_user_expired, -> { where('dossiers.hidden_by_user_at < ?', 1.week.ago) } scope :deleted_by_administration_expired, -> { where('dossiers.hidden_by_administration_at < ?', 1.week.ago) } - scope :en_brouillon_expired_to_delete, -> { state_brouillon.deleted_by_user_expired } - scope :en_construction_expired_to_delete, -> { state_en_construction.deleted_by_user_expired } - scope :termine_expired_to_delete, -> { state_termine.deleted_by_user_expired.deleted_by_administration_expired } + scope :deleted_by_automatic_expired, -> { where('dossiers.hidden_by_expired_at < ?', 1.week.ago) } + scope :en_brouillon_expired_to_delete, -> { state_brouillon.deleted_by_user_expired.or(state_brouillon.deleted_by_automatic_expired) } + scope :en_construction_expired_to_delete, -> { state_en_construction.deleted_by_user_expired.or(state_en_construction.deleted_by_automatic_expired) } + scope :termine_expired_to_delete, -> { state_termine.deleted_by_user_expired.deleted_by_administration_expired.or(state_termine.deleted_by_automatic_expired) } scope :brouillon_near_procedure_closing_date, -> do # select users who have submitted dossier for the given 'procedures.id' diff --git a/spec/jobs/cron/discarded_dossiers_deletion_job_spec.rb b/spec/jobs/cron/discarded_dossiers_deletion_job_spec.rb index 197daa6c2..c69c54de2 100644 --- a/spec/jobs/cron/discarded_dossiers_deletion_job_spec.rb +++ b/spec/jobs/cron/discarded_dossiers_deletion_job_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Cron::DiscardedDossiersDeletionJob, type: :job do dossier.send(:log_dossier_operation, instructeur, :supprimer, dossier) dossier.update_columns(hidden_by_user_at: hidden_at, hidden_by_administration_at: hidden_at) dossier.update_column(:hidden_by_reason, "user_request") - dossier_2.update_columns(hidden_by_user_at: hidden_at, hidden_by_administration_at: hidden_at) + dossier_2.update_columns(hidden_by_expired_at: hidden_at) dossier_2.update_column(:hidden_by_reason, "expired") end