Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-06 18:13:23 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-06 18:13:23 +0300
commitb333706699e505b2a0a4fa9cc64b9d2358f271a5 (patch)
tree8d7f450089b32bcf038269c5e2849887b45c212d /spec/workers/projects
parent65b6ccd12e2e440baafd88851470d032c6ebe2c5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/projects')
-rw-r--r--spec/workers/projects/inactive_projects_deletion_cron_worker_spec.rb92
1 files changed, 32 insertions, 60 deletions
diff --git a/spec/workers/projects/inactive_projects_deletion_cron_worker_spec.rb b/spec/workers/projects/inactive_projects_deletion_cron_worker_spec.rb
index ec10c66968d..50b5b0a6e7b 100644
--- a/spec/workers/projects/inactive_projects_deletion_cron_worker_spec.rb
+++ b/spec/workers/projects/inactive_projects_deletion_cron_worker_spec.rb
@@ -85,86 +85,58 @@ RSpec.describe Projects::InactiveProjectsDeletionCronWorker do
end
end
- context 'when delete inactive projects feature is enabled' do
+ context 'when delete inactive projects feature is enabled', :clean_gitlab_redis_shared_state, :sidekiq_inline do
before do
stub_application_setting(delete_inactive_projects: true)
end
- context 'when feature flag is disabled' do
- before do
- stub_feature_flags(inactive_projects_deletion: false)
- end
-
- it 'does not invoke Projects::InactiveProjectsDeletionNotificationWorker' do
- expect(::Projects::InactiveProjectsDeletionNotificationWorker).not_to receive(:perform_async)
- expect(::Projects::DestroyService).not_to receive(:new)
-
- worker.perform
- end
-
- it 'does not delete the inactive projects' do
- worker.perform
-
- expect(inactive_large_project.reload.pending_delete).to eq(false)
+ it 'invokes Projects::InactiveProjectsDeletionNotificationWorker for inactive projects' do
+ Gitlab::Redis::SharedState.with do |redis|
+ expect(redis).to receive(:hset).with('inactive_projects_deletion_warning_email_notified',
+ "project:#{inactive_large_project.id}", Date.current)
end
+ expect(::Projects::InactiveProjectsDeletionNotificationWorker).to receive(:perform_async).with(
+ inactive_large_project.id, deletion_date).and_call_original
+ expect(::Projects::DestroyService).not_to receive(:new)
- it_behaves_like 'worker is running for more than 4 minutes'
- it_behaves_like 'worker finishes processing in less than 4 minutes'
+ worker.perform
end
- context 'when feature flag is enabled', :clean_gitlab_redis_shared_state, :sidekiq_inline do
- before do
- stub_feature_flags(inactive_projects_deletion: true)
- end
-
- it 'invokes Projects::InactiveProjectsDeletionNotificationWorker for inactive projects' do
- Gitlab::Redis::SharedState.with do |redis|
- expect(redis).to receive(:hset).with('inactive_projects_deletion_warning_email_notified',
- "project:#{inactive_large_project.id}", Date.current)
- end
- expect(::Projects::InactiveProjectsDeletionNotificationWorker).to receive(:perform_async).with(
- inactive_large_project.id, deletion_date).and_call_original
- expect(::Projects::DestroyService).not_to receive(:new)
-
- worker.perform
+ it 'does not invoke InactiveProjectsDeletionNotificationWorker for already notified inactive projects' do
+ Gitlab::Redis::SharedState.with do |redis|
+ redis.hset('inactive_projects_deletion_warning_email_notified', "project:#{inactive_large_project.id}",
+ Date.current.to_s)
end
- it 'does not invoke InactiveProjectsDeletionNotificationWorker for already notified inactive projects' do
- Gitlab::Redis::SharedState.with do |redis|
- redis.hset('inactive_projects_deletion_warning_email_notified', "project:#{inactive_large_project.id}",
- Date.current.to_s)
- end
+ expect(::Projects::InactiveProjectsDeletionNotificationWorker).not_to receive(:perform_async)
+ expect(::Projects::DestroyService).not_to receive(:new)
- expect(::Projects::InactiveProjectsDeletionNotificationWorker).not_to receive(:perform_async)
- expect(::Projects::DestroyService).not_to receive(:new)
+ worker.perform
+ end
- worker.perform
+ it 'invokes Projects::DestroyService for projects that are inactive even after being notified' do
+ Gitlab::Redis::SharedState.with do |redis|
+ redis.hset('inactive_projects_deletion_warning_email_notified', "project:#{inactive_large_project.id}",
+ 15.months.ago.to_date.to_s)
end
- it 'invokes Projects::DestroyService for projects that are inactive even after being notified' do
- Gitlab::Redis::SharedState.with do |redis|
- redis.hset('inactive_projects_deletion_warning_email_notified', "project:#{inactive_large_project.id}",
- 15.months.ago.to_date.to_s)
- end
-
- expect(::Projects::InactiveProjectsDeletionNotificationWorker).not_to receive(:perform_async)
- expect(::Projects::DestroyService).to receive(:new).with(inactive_large_project, admin_user, {})
- .at_least(:once).and_call_original
+ expect(::Projects::InactiveProjectsDeletionNotificationWorker).not_to receive(:perform_async)
+ expect(::Projects::DestroyService).to receive(:new).with(inactive_large_project, admin_user, {})
+ .at_least(:once).and_call_original
- worker.perform
+ worker.perform
- expect(inactive_large_project.reload.pending_delete).to eq(true)
+ expect(inactive_large_project.reload.pending_delete).to eq(true)
- Gitlab::Redis::SharedState.with do |redis|
- expect(redis.hget('inactive_projects_deletion_warning_email_notified',
- "project:#{inactive_large_project.id}")).to be_nil
- end
+ Gitlab::Redis::SharedState.with do |redis|
+ expect(redis.hget('inactive_projects_deletion_warning_email_notified',
+ "project:#{inactive_large_project.id}")).to be_nil
end
-
- it_behaves_like 'worker is running for more than 4 minutes'
- it_behaves_like 'worker finishes processing in less than 4 minutes'
end
+ it_behaves_like 'worker is running for more than 4 minutes'
+ it_behaves_like 'worker finishes processing in less than 4 minutes'
+
it_behaves_like 'an idempotent worker'
end
end