From fd81936baf7521d8b1821cddfc0627730dc9b133 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 21 Nov 2023 10:18:58 +0100 Subject: [PATCH] correctif(users.expires): maj l'appel a process_expired car le service est instanciable maintenant --- app/jobs/cron/expired_users_deletion_job.rb | 2 +- spec/jobs/cron/expired_users_deletion_job_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/jobs/cron/expired_users_deletion_job.rb b/app/jobs/cron/expired_users_deletion_job.rb index 3552fd4e9..1dd923a81 100644 --- a/app/jobs/cron/expired_users_deletion_job.rb +++ b/app/jobs/cron/expired_users_deletion_job.rb @@ -4,6 +4,6 @@ class Cron::ExpiredUsersDeletionJob < Cron::CronJob def perform(*args) return if ENV['EXPIRE_USER_DELETION_JOB_LIMIT'].blank? - Expired::UsersDeletionService.process_expired + Expired::UsersDeletionService.new.process_expired end end diff --git a/spec/jobs/cron/expired_users_deletion_job_spec.rb b/spec/jobs/cron/expired_users_deletion_job_spec.rb index 870052af7..3d3a7b179 100644 --- a/spec/jobs/cron/expired_users_deletion_job_spec.rb +++ b/spec/jobs/cron/expired_users_deletion_job_spec.rb @@ -5,19 +5,19 @@ describe Cron::ExpiredUsersDeletionJob do before { expect(ENV).to receive(:[]).with('EXPIRE_USER_DELETION_JOB_LIMIT').and_return('anything') } it 'calls Expired::UsersDeletionService.process_expired' do - expect(Expired::UsersDeletionService).to receive(:process_expired) + expect_any_instance_of(Expired::UsersDeletionService).to receive(:process_expired) subject end it 'fails gracefuly by catching any error (to prevent re-enqueue and sending too much email)' do - expect(Expired::UsersDeletionService).to receive(:process_expired).and_raise(StandardError) + expect_any_instance_of(Expired::UsersDeletionService).to receive(:process_expired).and_raise(StandardError) expect { subject }.not_to raise_error end end context 'when env[EXPIRE_USER_DELETION_JOB_LIMIT] is absent' do it 'does not call Expired::UsersDeletionService.process_expired' do - expect(Expired::UsersDeletionService).not_to receive(:process_expired) + expect_any_instance_of(Expired::UsersDeletionService).not_to receive(:process_expired) subject end end