correctif(users.expires): maj l'appel a process_expired car le service est instanciable maintenant

This commit is contained in:
Martin 2023-11-21 10:18:58 +01:00
parent 7cb6eadf18
commit fd81936baf
2 changed files with 4 additions and 4 deletions

View file

@ -4,6 +4,6 @@ class Cron::ExpiredUsersDeletionJob < Cron::CronJob
def perform(*args) def perform(*args)
return if ENV['EXPIRE_USER_DELETION_JOB_LIMIT'].blank? return if ENV['EXPIRE_USER_DELETION_JOB_LIMIT'].blank?
Expired::UsersDeletionService.process_expired Expired::UsersDeletionService.new.process_expired
end end
end end

View file

@ -5,19 +5,19 @@ describe Cron::ExpiredUsersDeletionJob do
before { expect(ENV).to receive(:[]).with('EXPIRE_USER_DELETION_JOB_LIMIT').and_return('anything') } before { expect(ENV).to receive(:[]).with('EXPIRE_USER_DELETION_JOB_LIMIT').and_return('anything') }
it 'calls Expired::UsersDeletionService.process_expired' do 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 subject
end end
it 'fails gracefuly by catching any error (to prevent re-enqueue and sending too much email)' do 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 expect { subject }.not_to raise_error
end end
end end
context 'when env[EXPIRE_USER_DELETION_JOB_LIMIT] is absent' do context 'when env[EXPIRE_USER_DELETION_JOB_LIMIT] is absent' do
it 'does not call Expired::UsersDeletionService.process_expired' 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 subject
end end
end end