blob: 2fd84d0e085f03e84fd175528e15569e61cc0e79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe UserStatusCleanup::BatchWorker do
include_examples 'an idempotent worker' do
subject do
perform_multiple([], worker: described_class.new)
end
end
describe '#perform' do
subject(:run_worker) { described_class.new.perform }
context 'when no records are scheduled for cleanup' do
let(:user_status) { create(:user_status) }
it 'does nothing' do
expect { run_worker }.not_to change { user_status.reload }
end
end
it 'cleans up the records' do
user_status_1 = create(:user_status, clear_status_at: 1.year.ago)
user_status_2 = create(:user_status, clear_status_at: 2.years.ago)
run_worker
deleted_statuses = UserStatus.where(user_id: [user_status_1.user_id, user_status_2.user_id])
expect(deleted_statuses).to be_empty
end
end
end
|