2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-03 09:22:03 +01:00
|
|
|
describe Cron::ExpiredUsersDeletionJob do
|
|
|
|
subject { described_class.perform_now }
|
|
|
|
|
2023-11-04 08:45:40 +01:00
|
|
|
context 'when env[EXPIRE_USER_DELETION_JOB_LIMIT] is present' do
|
|
|
|
before { expect(ENV).to receive(:[]).with('EXPIRE_USER_DELETION_JOB_LIMIT').and_return('anything') }
|
2023-11-03 09:22:03 +01:00
|
|
|
|
2023-11-07 07:24:57 +01:00
|
|
|
it 'calls Expired::UsersDeletionService.process_expired' do
|
2023-11-21 10:18:58 +01:00
|
|
|
expect_any_instance_of(Expired::UsersDeletionService).to receive(:process_expired)
|
2023-11-03 09:22:03 +01:00
|
|
|
subject
|
|
|
|
end
|
2023-11-09 18:43:01 +01:00
|
|
|
|
|
|
|
it 'fails gracefuly by catching any error (to prevent re-enqueue and sending too much email)' do
|
2023-11-21 10:18:58 +01:00
|
|
|
expect_any_instance_of(Expired::UsersDeletionService).to receive(:process_expired).and_raise(StandardError)
|
2023-11-09 18:43:01 +01:00
|
|
|
expect { subject }.not_to raise_error
|
|
|
|
end
|
2023-11-03 09:22:03 +01:00
|
|
|
end
|
|
|
|
|
2023-11-04 08:45:40 +01:00
|
|
|
context 'when env[EXPIRE_USER_DELETION_JOB_LIMIT] is absent' do
|
2023-11-07 07:24:57 +01:00
|
|
|
it 'does not call Expired::UsersDeletionService.process_expired' do
|
2023-11-21 10:18:58 +01:00
|
|
|
expect_any_instance_of(Expired::UsersDeletionService).not_to receive(:process_expired)
|
2023-11-03 09:22:03 +01:00
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|