diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/workers/user_status_cleanup | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/workers/user_status_cleanup')
-rw-r--r-- | spec/workers/user_status_cleanup/batch_worker_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/workers/user_status_cleanup/batch_worker_spec.rb b/spec/workers/user_status_cleanup/batch_worker_spec.rb new file mode 100644 index 00000000000..2fd84d0e085 --- /dev/null +++ b/spec/workers/user_status_cleanup/batch_worker_spec.rb @@ -0,0 +1,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 |