diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index e5434de97..510d65791 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -69,7 +69,7 @@ class UserMailer < ApplicationMailer def notify_inactive_close_to_deletion(user) @user = user - @subject = "Votre compte sera supprimé dans #{Expired::UsersDeletionService::RETENTION_AFTER_NOTICE_IN_WEEK} semaines" + @subject = "Votre compte sera supprimé dans #{Expired::REMAINING_WEEKS_BEFORE_EXPIRATION} semaines" mail(to: user.email, subject: @subject) end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 5a32acf74..3bf8597dc 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -25,8 +25,7 @@ class Dossier < ApplicationRecord REMAINING_DAYS_BEFORE_CLOSING = 2 INTERVAL_BEFORE_CLOSING = "#{REMAINING_DAYS_BEFORE_CLOSING} days" - REMAINING_WEEKS_BEFORE_EXPIRATION = 2 - INTERVAL_BEFORE_EXPIRATION = "#{REMAINING_WEEKS_BEFORE_EXPIRATION} weeks" + INTERVAL_BEFORE_EXPIRATION = "#{Expired::REMAINING_WEEKS_BEFORE_EXPIRATION} weeks" MONTHS_AFTER_EXPIRATION = 1 DAYS_AFTER_EXPIRATION = 5 INTERVAL_EXPIRATION = "#{MONTHS_AFTER_EXPIRATION} month #{DAYS_AFTER_EXPIRATION} days" @@ -625,7 +624,7 @@ class Dossier < ApplicationRecord end def expiration_notification_date - expiration_date_with_extension - REMAINING_WEEKS_BEFORE_EXPIRATION.weeks + expiration_date_with_extension - Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks end def close_to_expiration? diff --git a/app/services/expired.rb b/app/services/expired.rb index dc9ab19ef..cadf77fcf 100644 --- a/app/services/expired.rb +++ b/app/services/expired.rb @@ -1,4 +1,6 @@ module Expired + REMAINING_WEEKS_BEFORE_EXPIRATION = 2 + def self.schedule_at(caller) case caller.name when 'Cron::ExpiredPrefilledDossiersDeletionJob' diff --git a/app/services/expired/users_deletion_service.rb b/app/services/expired/users_deletion_service.rb index 8294dc112..0a4904508 100644 --- a/app/services/expired/users_deletion_service.rb +++ b/app/services/expired/users_deletion_service.rb @@ -1,5 +1,4 @@ class Expired::UsersDeletionService < Expired::MailRateLimiter - RETENTION_AFTER_NOTICE_IN_WEEK = 2 EXPIRABLE_AFTER_IN_YEAR = 2 def process_expired @@ -60,7 +59,7 @@ class Expired::UsersDeletionService < Expired::MailRateLimiter end def to_delete_only(users) - users.where.not(inactive_close_to_expiration_notice_sent_at: RETENTION_AFTER_NOTICE_IN_WEEK.weeks.ago..) + users.where.not(inactive_close_to_expiration_notice_sent_at: Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks.ago..) end def limit diff --git a/app/views/dossier_mailer/notify_automatic_deletion_to_user.html.haml b/app/views/dossier_mailer/notify_automatic_deletion_to_user.html.haml index 9d45212f8..8d2079e12 100644 --- a/app/views/dossier_mailer/notify_automatic_deletion_to_user.html.haml +++ b/app/views/dossier_mailer/notify_automatic_deletion_to_user.html.haml @@ -12,6 +12,6 @@ %strong= t('.account_active', count: @deleted_dossiers.size) - if @state == Dossier.states.fetch(:en_construction) - %p= t('.footer_en_construction', count: @deleted_dossiers.size) + %p= t('.footer_en_construction', count: @deleted_dossiers.size, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks)) = render partial: "layouts/mailers/signature" diff --git a/app/views/dossier_mailer/notify_near_deletion_to_administration.html.haml b/app/views/dossier_mailer/notify_near_deletion_to_administration.html.haml index a1d769e93..1bd80d74b 100644 --- a/app/views/dossier_mailer/notify_near_deletion_to_administration.html.haml +++ b/app/views/dossier_mailer/notify_near_deletion_to_administration.html.haml @@ -14,8 +14,8 @@ %p - if @state == Dossier.states.fetch(:en_construction) - = sanitize(t('.footer_en_construction', count: @dossiers.size)) + = sanitize(t('.footer_en_construction', count: @dossiers.size, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks))) - else - = sanitize(t('.footer_termine', count: @dossiers.size)) + = sanitize(t('.footer_termine', count: @dossiers.size, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks))) = render partial: "layouts/mailers/signature" diff --git a/app/views/dossier_mailer/notify_near_deletion_to_user.html.haml b/app/views/dossier_mailer/notify_near_deletion_to_user.html.haml index f7e81d468..be5eeaa32 100644 --- a/app/views/dossier_mailer/notify_near_deletion_to_user.html.haml +++ b/app/views/dossier_mailer/notify_near_deletion_to_user.html.haml @@ -17,8 +17,8 @@ %p - if @state == Dossier.states.fetch(:en_construction) - = sanitize(t('.footer_en_construction', count: @dossiers.size)) + = sanitize(t('.footer_en_construction', count: @dossiers.size, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks))) - else - = sanitize(t('.footer_termine', count: @dossiers.size, dossiers_url: dossiers_url)) + = sanitize(t('.footer_termine', count: @dossiers.size, dossiers_url: dossiers_url, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks))) = render partial: "layouts/mailers/signature" diff --git a/app/views/user_mailer/notify_inactive_close_to_deletion.html.haml b/app/views/user_mailer/notify_inactive_close_to_deletion.html.haml index 512d24c67..3e6a08582 100644 --- a/app/views/user_mailer/notify_inactive_close_to_deletion.html.haml +++ b/app/views/user_mailer/notify_inactive_close_to_deletion.html.haml @@ -7,7 +7,7 @@ Cela fait plus de deux ans que vous ne vous êtes pas connecté à #{APPLICATION_NAME}. %br Dans le respect du RGPD, nous allons - %strong supprimer votre compte d'ici #{distance_of_time_in_words(ExpiredUsersDeletionService::RETENTION_AFTER_NOTICE_IN_WEEK.weeks)}. + %strong supprimer votre compte d'ici #{distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks)}. %p %strong Ne vous en faites pas, diff --git a/config/locales/views/dossier_mailer/notify_near_deletion_to_administration/fr.yml b/config/locales/views/dossier_mailer/notify_near_deletion_to_administration/fr.yml index cba9b626b..42d48bf06 100644 --- a/config/locales/views/dossier_mailer/notify_near_deletion_to_administration/fr.yml +++ b/config/locales/views/dossier_mailer/notify_near_deletion_to_administration/fr.yml @@ -14,8 +14,8 @@ fr: one: "Le dossier suivant dont le traitement est terminé sera bientôt automatiquement supprimé :" other: "Les dossiers suivants dont le traitement est terminé seront bientôt automatiquement supprimés :" footer_en_construction: - one: "Vous avez deux semaines pour commencer l’instruction du dossier." - other: "Vous avez deux semaines pour commencer l’instruction des dossiers." + one: "Vous avez %{remaining_weeks_before_expiration} pour commencer l’instruction du dossier." + other: "Vous avez %{remaining_weeks_before_expiration} pour commencer l’instruction des dossiers." footer_termine: - one: "Vous avez deux semaines pour archiver le dossier." - other: "Vous avez deux semaines pour archiver les dossiers." + one: "Vous avez %{remaining_weeks_before_expiration} pour archiver le dossier." + other: "Vous avez %{remaining_weeks_before_expiration} pour archiver les dossiers." diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index 449465f63..8a3aebe1e 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -152,7 +152,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.body).to include("N° #{dossier.id} ") } it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include("PDF") } - it { expect(subject.body).to include("Vous avez deux semaines pour commencer l’instruction du dossier.") } + it { expect(subject.body).to include("Vous avez 14 jours pour commencer l’instruction du dossier.") } end describe 'termine' do diff --git a/spec/services/expired/expired_users_deletion_service_spec.rb b/spec/services/expired/expired_users_deletion_service_spec.rb index 8871e2280..5f315f127 100644 --- a/spec/services/expired/expired_users_deletion_service_spec.rb +++ b/spec/services/expired/expired_users_deletion_service_spec.rb @@ -2,8 +2,8 @@ describe Expired::UsersDeletionService do let(:last_signed_in_not_expired) { (Expired::UsersDeletionService::EXPIRABLE_AFTER_IN_YEAR - 1).years.ago } let(:last_signed_in_expired) { (Expired::UsersDeletionService::EXPIRABLE_AFTER_IN_YEAR + 1).years.ago } let(:before_close_to_expiration) { nil } - let(:notified_close_to_expiration) { (Expired::UsersDeletionService::RETENTION_AFTER_NOTICE_IN_WEEK - 1).weeks.ago } - let(:due_close_to_expiration) { (Expired::UsersDeletionService::RETENTION_AFTER_NOTICE_IN_WEEK + 1).weeks.ago } + let(:notified_close_to_expiration) { (Expired::REMAINING_WEEKS_BEFORE_EXPIRATION - 1).weeks.ago } + let(:due_close_to_expiration) { (Expired::REMAINING_WEEKS_BEFORE_EXPIRATION + 1).weeks.ago } let(:mail_double) do dbl = double() expect(dbl).to receive(:deliver_later).with(wait: 0)