diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/workers | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/workers')
212 files changed, 739 insertions, 486 deletions
diff --git a/spec/workers/admin_email_worker_spec.rb b/spec/workers/admin_email_worker_spec.rb index f72b932423f..1a5cb90bc17 100644 --- a/spec/workers/admin_email_worker_spec.rb +++ b/spec/workers/admin_email_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AdminEmailWorker do +RSpec.describe AdminEmailWorker do subject(:worker) { described_class.new } describe '.perform' do diff --git a/spec/workers/archive_trace_worker_spec.rb b/spec/workers/archive_trace_worker_spec.rb index 44f7be15201..a9f256b1b3b 100644 --- a/spec/workers/archive_trace_worker_spec.rb +++ b/spec/workers/archive_trace_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ArchiveTraceWorker do +RSpec.describe ArchiveTraceWorker do describe '#perform' do subject { described_class.new.perform(job&.id) } diff --git a/spec/workers/authorized_keys_worker_spec.rb b/spec/workers/authorized_keys_worker_spec.rb index 4f1dde0bfc0..50236f9ea7b 100644 --- a/spec/workers/authorized_keys_worker_spec.rb +++ b/spec/workers/authorized_keys_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AuthorizedKeysWorker do +RSpec.describe AuthorizedKeysWorker do let(:worker) { described_class.new } describe '#perform' do diff --git a/spec/workers/authorized_project_update/periodic_recalculate_worker_spec.rb b/spec/workers/authorized_project_update/periodic_recalculate_worker_spec.rb index fcd073953b6..2d633828ae3 100644 --- a/spec/workers/authorized_project_update/periodic_recalculate_worker_spec.rb +++ b/spec/workers/authorized_project_update/periodic_recalculate_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AuthorizedProjectUpdate::PeriodicRecalculateWorker do +RSpec.describe AuthorizedProjectUpdate::PeriodicRecalculateWorker do describe '#perform' do it 'calls AuthorizedProjectUpdate::PeriodicRecalculateService' do expect_next_instance_of(AuthorizedProjectUpdate::PeriodicRecalculateService) do |service| diff --git a/spec/workers/authorized_project_update/project_create_worker_spec.rb b/spec/workers/authorized_project_update/project_create_worker_spec.rb index 5ebfb60bc79..5226ab30de7 100644 --- a/spec/workers/authorized_project_update/project_create_worker_spec.rb +++ b/spec/workers/authorized_project_update/project_create_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AuthorizedProjectUpdate::ProjectCreateWorker do +RSpec.describe AuthorizedProjectUpdate::ProjectCreateWorker do let_it_be(:group) { create(:group, :private) } let_it_be(:group_project) { create(:project, group: group) } let_it_be(:group_user) { create(:user) } @@ -27,7 +27,7 @@ describe AuthorizedProjectUpdate::ProjectCreateWorker do context 'idempotence' do before do - create(:group_member, access_level: Gitlab::Access::MAINTAINER, group: group, user: group_user) + create(:group_member, access_level: access_level, group: group, user: group_user) ProjectAuthorization.delete_all end diff --git a/spec/workers/authorized_project_update/project_group_link_create_worker_spec.rb b/spec/workers/authorized_project_update/project_group_link_create_worker_spec.rb new file mode 100644 index 00000000000..7c4ad4ce641 --- /dev/null +++ b/spec/workers/authorized_project_update/project_group_link_create_worker_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe AuthorizedProjectUpdate::ProjectGroupLinkCreateWorker do + let_it_be(:group) { create(:group, :private) } + let_it_be(:group_project) { create(:project, group: group) } + let_it_be(:shared_with_group) { create(:group, :private) } + let_it_be(:user) { create(:user) } + + let(:access_level) { Gitlab::Access::MAINTAINER } + + subject(:worker) { described_class.new } + + it 'calls AuthorizedProjectUpdate::ProjectCreateService' do + expect_next_instance_of(AuthorizedProjectUpdate::ProjectGroupLinkCreateService) do |service| + expect(service).to(receive(:execute)) + end + + worker.perform(group_project.id, shared_with_group.id) + end + + it 'returns ServiceResponse.success' do + result = worker.perform(group_project.id, shared_with_group.id) + + expect(result.success?).to be_truthy + end + + context 'idempotence' do + before do + create(:group_member, group: shared_with_group, user: user, access_level: access_level) + create(:project_group_link, project: group_project, group: shared_with_group) + ProjectAuthorization.delete_all + end + + include_examples 'an idempotent worker' do + let(:job_args) { [group_project.id, shared_with_group.id] } + + it 'creates project authorization' do + subject + + project_authorization = ProjectAuthorization.where( + project_id: group_project.id, + user_id: user.id, + access_level: access_level) + + expect(project_authorization).to exist + expect(ProjectAuthorization.count).to eq(1) + end + end + end +end diff --git a/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb b/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb index 5d1c405dfd0..c49e4c453bf 100644 --- a/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb +++ b/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker do +RSpec.describe AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker do let(:start_user_id) { 42 } let(:end_user_id) { 4242 } diff --git a/spec/workers/authorized_project_update/user_refresh_with_low_urgency_worker_spec.rb b/spec/workers/authorized_project_update/user_refresh_with_low_urgency_worker_spec.rb index fa029dae0fa..bd16eeb4712 100644 --- a/spec/workers/authorized_project_update/user_refresh_with_low_urgency_worker_spec.rb +++ b/spec/workers/authorized_project_update/user_refresh_with_low_urgency_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker do +RSpec.describe AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker do it 'is labeled as low urgency' do expect(described_class.get_urgency).to eq(:low) end diff --git a/spec/workers/authorized_projects_worker_spec.rb b/spec/workers/authorized_projects_worker_spec.rb index 93f22471c56..fbfde77be97 100644 --- a/spec/workers/authorized_projects_worker_spec.rb +++ b/spec/workers/authorized_projects_worker_spec.rb @@ -2,6 +2,6 @@ require 'spec_helper' -describe AuthorizedProjectsWorker do +RSpec.describe AuthorizedProjectsWorker do it_behaves_like "refreshes user's project authorizations" end diff --git a/spec/workers/auto_devops/disable_worker_spec.rb b/spec/workers/auto_devops/disable_worker_spec.rb index 53113f286ba..239f4b09f5c 100644 --- a/spec/workers/auto_devops/disable_worker_spec.rb +++ b/spec/workers/auto_devops/disable_worker_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe AutoDevops::DisableWorker, '#perform' do +RSpec.describe AutoDevops::DisableWorker, '#perform' do let(:user) { create(:user, developer_projects: [project]) } let(:project) { create(:project, :repository, :auto_devops) } let(:auto_devops) { project.auto_devops } diff --git a/spec/workers/auto_merge_process_worker_spec.rb b/spec/workers/auto_merge_process_worker_spec.rb index 616727ce5ca..00d27d9c2b5 100644 --- a/spec/workers/auto_merge_process_worker_spec.rb +++ b/spec/workers/auto_merge_process_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe AutoMergeProcessWorker do +RSpec.describe AutoMergeProcessWorker do describe '#perform' do subject { described_class.new.perform(merge_request&.id) } diff --git a/spec/workers/background_migration_worker_spec.rb b/spec/workers/background_migration_worker_spec.rb index 2b2ffc9f5b9..15e93d62c7d 100644 --- a/spec/workers/background_migration_worker_spec.rb +++ b/spec/workers/background_migration_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe BackgroundMigrationWorker, :clean_gitlab_redis_shared_state do +RSpec.describe BackgroundMigrationWorker, :clean_gitlab_redis_shared_state do let(:worker) { described_class.new } describe '.minimum_interval' do diff --git a/spec/workers/build_coverage_worker_spec.rb b/spec/workers/build_coverage_worker_spec.rb index 25686ae68ca..4beb6e5972f 100644 --- a/spec/workers/build_coverage_worker_spec.rb +++ b/spec/workers/build_coverage_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe BuildCoverageWorker do +RSpec.describe BuildCoverageWorker do describe '#perform' do context 'when build exists' do let!(:build) { create(:ci_build) } diff --git a/spec/workers/build_finished_worker_spec.rb b/spec/workers/build_finished_worker_spec.rb index 849563d9608..e7f7ae84621 100644 --- a/spec/workers/build_finished_worker_spec.rb +++ b/spec/workers/build_finished_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe BuildFinishedWorker do +RSpec.describe BuildFinishedWorker do subject { described_class.new.perform(build.id) } describe '#perform' do diff --git a/spec/workers/build_hooks_worker_spec.rb b/spec/workers/build_hooks_worker_spec.rb index 59b252a8be3..aefbd7e590e 100644 --- a/spec/workers/build_hooks_worker_spec.rb +++ b/spec/workers/build_hooks_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe BuildHooksWorker do +RSpec.describe BuildHooksWorker do describe '#perform' do context 'when build exists' do let!(:build) { create(:ci_build) } diff --git a/spec/workers/build_success_worker_spec.rb b/spec/workers/build_success_worker_spec.rb index f4ff8cb15f8..0583d79ed46 100644 --- a/spec/workers/build_success_worker_spec.rb +++ b/spec/workers/build_success_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe BuildSuccessWorker do +RSpec.describe BuildSuccessWorker do describe '#perform' do subject { described_class.new.perform(build.id) } diff --git a/spec/workers/build_trace_sections_worker_spec.rb b/spec/workers/build_trace_sections_worker_spec.rb index 97fc0a2da0c..1c84b0083fb 100644 --- a/spec/workers/build_trace_sections_worker_spec.rb +++ b/spec/workers/build_trace_sections_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe BuildTraceSectionsWorker do +RSpec.describe BuildTraceSectionsWorker do describe '#perform' do context 'when build exists' do let!(:build) { create(:ci_build) } diff --git a/spec/workers/chat_notification_worker_spec.rb b/spec/workers/chat_notification_worker_spec.rb index e4dccf2bf6b..a20a136d197 100644 --- a/spec/workers/chat_notification_worker_spec.rb +++ b/spec/workers/chat_notification_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ChatNotificationWorker do +RSpec.describe ChatNotificationWorker do let(:worker) { described_class.new } let(:chat_build) do create(:ci_build, pipeline: create(:ci_pipeline, source: :chat)) diff --git a/spec/workers/ci/archive_traces_cron_worker_spec.rb b/spec/workers/ci/archive_traces_cron_worker_spec.rb index 789e83783bb..14abe819587 100644 --- a/spec/workers/ci/archive_traces_cron_worker_spec.rb +++ b/spec/workers/ci/archive_traces_cron_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::ArchiveTracesCronWorker do +RSpec.describe Ci::ArchiveTracesCronWorker do subject { described_class.new.perform } let(:finished_at) { 1.day.ago } diff --git a/spec/workers/ci/build_prepare_worker_spec.rb b/spec/workers/ci/build_prepare_worker_spec.rb index 9f76696ee66..b2c74a920ea 100644 --- a/spec/workers/ci/build_prepare_worker_spec.rb +++ b/spec/workers/ci/build_prepare_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::BuildPrepareWorker do +RSpec.describe Ci::BuildPrepareWorker do subject { described_class.new.perform(build_id) } context 'build exists' do diff --git a/spec/workers/ci/build_report_result_worker_spec.rb b/spec/workers/ci/build_report_result_worker_spec.rb index 290a98366b4..aedfa70c8b8 100644 --- a/spec/workers/ci/build_report_result_worker_spec.rb +++ b/spec/workers/ci/build_report_result_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::BuildReportResultWorker do +RSpec.describe Ci::BuildReportResultWorker do subject { described_class.new.perform(build_id) } context 'when build exists' do diff --git a/spec/workers/ci/build_schedule_worker_spec.rb b/spec/workers/ci/build_schedule_worker_spec.rb index 647f9763fed..f8b4efc562b 100644 --- a/spec/workers/ci/build_schedule_worker_spec.rb +++ b/spec/workers/ci/build_schedule_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::BuildScheduleWorker do +RSpec.describe Ci::BuildScheduleWorker do subject { described_class.new.perform(build.id) } context 'when build is found' do diff --git a/spec/workers/ci/create_cross_project_pipeline_worker_spec.rb b/spec/workers/ci/create_cross_project_pipeline_worker_spec.rb index 492f5e812ee..95dcf5624cc 100644 --- a/spec/workers/ci/create_cross_project_pipeline_worker_spec.rb +++ b/spec/workers/ci/create_cross_project_pipeline_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::CreateCrossProjectPipelineWorker do +RSpec.describe Ci::CreateCrossProjectPipelineWorker do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } let_it_be(:pipeline) { create(:ci_pipeline, project: project) } diff --git a/spec/workers/ci/daily_build_group_report_results_worker_spec.rb b/spec/workers/ci/daily_build_group_report_results_worker_spec.rb index d9706982a62..e13c6311e46 100644 --- a/spec/workers/ci/daily_build_group_report_results_worker_spec.rb +++ b/spec/workers/ci/daily_build_group_report_results_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::DailyBuildGroupReportResultsWorker do +RSpec.describe Ci::DailyBuildGroupReportResultsWorker do describe '#perform' do let!(:pipeline) { create(:ci_pipeline) } diff --git a/spec/workers/ci/pipeline_bridge_status_worker_spec.rb b/spec/workers/ci/pipeline_bridge_status_worker_spec.rb index a6129b2cf93..6ec5eb0e639 100644 --- a/spec/workers/ci/pipeline_bridge_status_worker_spec.rb +++ b/spec/workers/ci/pipeline_bridge_status_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::PipelineBridgeStatusWorker do +RSpec.describe Ci::PipelineBridgeStatusWorker do describe '#perform' do subject { described_class.new.perform(pipeline_id) } diff --git a/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb b/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb new file mode 100644 index 00000000000..cb2cf58d50b --- /dev/null +++ b/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::PipelineSuccessUnlockArtifactsWorker do + describe '#perform' do + subject(:perform) { described_class.new.perform(pipeline_id) } + + include_examples 'an idempotent worker' do + subject(:idempotent_perform) { perform_multiple(pipeline.id, exec_times: 2) } + + let!(:older_pipeline) do + create(:ci_pipeline, :success, :with_job, locked: :artifacts_locked).tap do |pipeline| + create(:ci_job_artifact, job: pipeline.builds.first) + end + end + + let!(:pipeline) do + create(:ci_pipeline, :success, :with_job, ref: older_pipeline.ref, tag: older_pipeline.tag, project: older_pipeline.project, locked: :unlocked).tap do |pipeline| + create(:ci_job_artifact, job: pipeline.builds.first) + end + end + + it 'unlocks the artifacts from older pipelines' do + expect { idempotent_perform }.to change { older_pipeline.reload.locked }.from('artifacts_locked').to('unlocked') + end + end + + context 'when pipeline exists' do + let(:pipeline) { create(:ci_pipeline, :success, :with_job) } + let(:pipeline_id) { pipeline.id } + + context 'when pipeline has artifacts' do + before do + create(:ci_job_artifact, job: pipeline.builds.first) + end + + it 'calls the service' do + service = spy(Ci::UnlockArtifactsService) + expect(Ci::UnlockArtifactsService).to receive(:new).and_return(service) + + perform + + expect(service).to have_received(:execute) + end + end + + context 'when pipeline does not have artifacts' do + it 'does not call service' do + expect(Ci::UnlockArtifactsService).not_to receive(:new) + + perform + end + end + end + + context 'when pipeline does not exist' do + let(:pipeline_id) { non_existing_record_id } + + it 'does not call service' do + expect(Ci::UnlockArtifactsService).not_to receive(:new) + + perform + end + end + end +end diff --git a/spec/workers/ci/ref_delete_unlock_artifacts_worker_spec.rb b/spec/workers/ci/ref_delete_unlock_artifacts_worker_spec.rb new file mode 100644 index 00000000000..d9f2dd326dd --- /dev/null +++ b/spec/workers/ci/ref_delete_unlock_artifacts_worker_spec.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::RefDeleteUnlockArtifactsWorker do + describe '#perform' do + subject(:perform) { described_class.new.perform(project_id, user_id, ref) } + + let(:ref) { 'refs/heads/master' } + + let(:project) { create(:project) } + + include_examples 'an idempotent worker' do + subject(:idempotent_perform) { perform_multiple([project_id, user_id, ref], exec_times: 2) } + + let(:project_id) { project.id } + let(:user_id) { project.creator.id } + + let(:pipeline) { create(:ci_pipeline, ref: 'master', project: project, locked: :artifacts_locked) } + + it 'unlocks the artifacts from older pipelines' do + expect { idempotent_perform }.to change { pipeline.reload.locked }.from('artifacts_locked').to('unlocked') + end + end + + context 'when project exists' do + let(:project_id) { project.id } + + context 'when user exists' do + let(:user_id) { project.creator.id } + + context 'when ci ref exists' do + before do + create(:ci_ref, ref_path: ref) + end + + it 'calls the service' do + service = spy(Ci::UnlockArtifactsService) + expect(Ci::UnlockArtifactsService).to receive(:new).and_return(service) + + perform + + expect(service).to have_received(:execute) + end + end + + context 'when ci ref does not exist' do + it 'does not call the service' do + expect(Ci::UnlockArtifactsService).not_to receive(:new) + + perform + end + end + end + + context 'when user does not exist' do + let(:user_id) { non_existing_record_id } + + it 'does not call service' do + expect(Ci::UnlockArtifactsService).not_to receive(:new) + + perform + end + end + end + + context 'when project does not exist' do + let(:project_id) { non_existing_record_id } + let(:user_id) { project.creator.id } + + it 'does not call service' do + expect(Ci::UnlockArtifactsService).not_to receive(:new) + + perform + end + end + end +end diff --git a/spec/workers/ci/resource_groups/assign_resource_from_resource_group_worker_spec.rb b/spec/workers/ci/resource_groups/assign_resource_from_resource_group_worker_spec.rb index 634d932121e..f9914a7cecb 100644 --- a/spec/workers/ci/resource_groups/assign_resource_from_resource_group_worker_spec.rb +++ b/spec/workers/ci/resource_groups/assign_resource_from_resource_group_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::ResourceGroups::AssignResourceFromResourceGroupWorker do +RSpec.describe Ci::ResourceGroups::AssignResourceFromResourceGroupWorker do let(:worker) { described_class.new } describe '#perform' do diff --git a/spec/workers/cleanup_container_repository_worker_spec.rb b/spec/workers/cleanup_container_repository_worker_spec.rb index 1228c2c2d9c..0545f7a35e4 100644 --- a/spec/workers/cleanup_container_repository_worker_spec.rb +++ b/spec/workers/cleanup_container_repository_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do +RSpec.describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do let(:repository) { create(:container_repository) } let(:project) { repository.project } let(:user) { project.owner } diff --git a/spec/workers/cluster_configure_istio_worker_spec.rb b/spec/workers/cluster_configure_istio_worker_spec.rb index 0f02d428ced..5d949fde973 100644 --- a/spec/workers/cluster_configure_istio_worker_spec.rb +++ b/spec/workers/cluster_configure_istio_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ClusterConfigureIstioWorker do +RSpec.describe ClusterConfigureIstioWorker do describe '#perform' do shared_examples 'configure istio service' do it 'configures istio' do diff --git a/spec/workers/cluster_provision_worker_spec.rb b/spec/workers/cluster_provision_worker_spec.rb index 608639331fd..2d6ca4ab7e3 100644 --- a/spec/workers/cluster_provision_worker_spec.rb +++ b/spec/workers/cluster_provision_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ClusterProvisionWorker do +RSpec.describe ClusterProvisionWorker do describe '#perform' do context 'when provider type is gcp' do let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) } diff --git a/spec/workers/cluster_update_app_worker_spec.rb b/spec/workers/cluster_update_app_worker_spec.rb index 5391c194679..c24f40024fd 100644 --- a/spec/workers/cluster_update_app_worker_spec.rb +++ b/spec/workers/cluster_update_app_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ClusterUpdateAppWorker do +RSpec.describe ClusterUpdateAppWorker do include ExclusiveLeaseHelpers let_it_be(:project) { create(:project) } @@ -12,7 +12,7 @@ describe ClusterUpdateAppWorker do subject { described_class.new } around do |example| - Timecop.freeze(Time.now) { example.run } + Timecop.freeze(Time.current) { example.run } end before do @@ -22,11 +22,11 @@ describe ClusterUpdateAppWorker do describe '#perform' do context 'when the application last_update_started_at is higher than the time the job was scheduled in' do it 'does nothing' do - application = create(:clusters_applications_prometheus, :updated, last_update_started_at: Time.now) + application = create(:clusters_applications_prometheus, :updated, last_update_started_at: Time.current) expect(prometheus_update_service).not_to receive(:execute) - expect(subject.perform(application.name, application.id, project.id, Time.now - 5.minutes)).to be_nil + expect(subject.perform(application.name, application.id, project.id, Time.current - 5.minutes)).to be_nil end end @@ -34,7 +34,7 @@ describe ClusterUpdateAppWorker do it 'returns nil' do application = create(:clusters_applications_prometheus, :updating) - expect(subject.perform(application.name, application.id, project.id, Time.now)).to be_nil + expect(subject.perform(application.name, application.id, project.id, Time.current)).to be_nil end end @@ -43,7 +43,7 @@ describe ClusterUpdateAppWorker do expect(prometheus_update_service).to receive(:execute) - subject.perform(application.name, application.id, project.id, Time.now) + subject.perform(application.name, application.id, project.id, Time.current) end context 'with exclusive lease' do @@ -60,7 +60,7 @@ describe ClusterUpdateAppWorker do it 'does not allow same app to be updated concurrently by same project' do expect(Clusters::Applications::PrometheusUpdateService).not_to receive(:new) - subject.perform(application.name, application.id, project.id, Time.now) + subject.perform(application.name, application.id, project.id, Time.current) end it 'does not allow same app to be updated concurrently by different project', :aggregate_failures do @@ -68,7 +68,7 @@ describe ClusterUpdateAppWorker do expect(Clusters::Applications::PrometheusUpdateService).not_to receive(:new) - subject.perform(application.name, application.id, project1.id, Time.now) + subject.perform(application.name, application.id, project1.id, Time.current) end it 'allows different app to be updated concurrently by same project' do @@ -80,7 +80,7 @@ describe ClusterUpdateAppWorker do expect(Clusters::Applications::PrometheusUpdateService).to receive(:new) .with(application2, project) - subject.perform(application2.name, application2.id, project.id, Time.now) + subject.perform(application2.name, application2.id, project.id, Time.current) end it 'allows different app to be updated by different project', :aggregate_failures do @@ -94,7 +94,7 @@ describe ClusterUpdateAppWorker do expect(Clusters::Applications::PrometheusUpdateService).to receive(:new) .with(application2, project2) - subject.perform(application2.name, application2.id, project2.id, Time.now) + subject.perform(application2.name, application2.id, project2.id, Time.current) end end end diff --git a/spec/workers/cluster_wait_for_app_update_worker_spec.rb b/spec/workers/cluster_wait_for_app_update_worker_spec.rb index f1206bd85cb..b7f7622a0e6 100644 --- a/spec/workers/cluster_wait_for_app_update_worker_spec.rb +++ b/spec/workers/cluster_wait_for_app_update_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ClusterWaitForAppUpdateWorker do +RSpec.describe ClusterWaitForAppUpdateWorker do let(:check_upgrade_progress_service) { spy } before do diff --git a/spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb b/spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb index a9ffdfb085e..7a42c988a92 100644 --- a/spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb +++ b/spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ClusterWaitForIngressIpAddressWorker do +RSpec.describe ClusterWaitForIngressIpAddressWorker do describe '#perform' do let(:service) { instance_double(Clusters::Applications::CheckIngressIpAddressService, execute: true) } let(:application) { instance_double(Clusters::Applications::Ingress) } diff --git a/spec/workers/clusters/applications/activate_service_worker_spec.rb b/spec/workers/clusters/applications/activate_service_worker_spec.rb index 09f4c536edf..c157c57888e 100644 --- a/spec/workers/clusters/applications/activate_service_worker_spec.rb +++ b/spec/workers/clusters/applications/activate_service_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::ActivateServiceWorker, '#perform' do +RSpec.describe Clusters::Applications::ActivateServiceWorker, '#perform' do context 'cluster exists' do describe 'prometheus service' do let(:service_name) { 'prometheus' } diff --git a/spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb b/spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb index a09b9ec4165..5a37031a55a 100644 --- a/spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb +++ b/spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::CheckPrometheusHealthWorker, '#perform' do +RSpec.describe Clusters::Applications::CheckPrometheusHealthWorker, '#perform' do subject { described_class.new.perform } it 'triggers health service' do diff --git a/spec/workers/clusters/applications/deactivate_service_worker_spec.rb b/spec/workers/clusters/applications/deactivate_service_worker_spec.rb index 809843a1bc8..18cceaaf3b1 100644 --- a/spec/workers/clusters/applications/deactivate_service_worker_spec.rb +++ b/spec/workers/clusters/applications/deactivate_service_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::DeactivateServiceWorker, '#perform' do +RSpec.describe Clusters::Applications::DeactivateServiceWorker, '#perform' do context 'cluster exists' do describe 'prometheus service' do let(:service_name) { 'prometheus' } diff --git a/spec/workers/clusters/applications/wait_for_uninstall_app_worker_spec.rb b/spec/workers/clusters/applications/wait_for_uninstall_app_worker_spec.rb index aaf5c9defc4..0191a2898b2 100644 --- a/spec/workers/clusters/applications/wait_for_uninstall_app_worker_spec.rb +++ b/spec/workers/clusters/applications/wait_for_uninstall_app_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Applications::WaitForUninstallAppWorker, '#perform' do +RSpec.describe Clusters::Applications::WaitForUninstallAppWorker, '#perform' do let(:app) { create(:clusters_applications_helm) } let(:app_name) { app.name } let(:app_id) { app.id } diff --git a/spec/workers/clusters/cleanup/app_worker_spec.rb b/spec/workers/clusters/cleanup/app_worker_spec.rb index 29c00db8079..661468f037f 100644 --- a/spec/workers/clusters/cleanup/app_worker_spec.rb +++ b/spec/workers/clusters/cleanup/app_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Cleanup::AppWorker do +RSpec.describe Clusters::Cleanup::AppWorker do describe '#perform' do subject { worker_instance.perform(cluster.id) } diff --git a/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb b/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb index 8b6f22e9a61..b9219586a0b 100644 --- a/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb +++ b/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Cleanup::ProjectNamespaceWorker do +RSpec.describe Clusters::Cleanup::ProjectNamespaceWorker do describe '#perform' do context 'when cluster.cleanup_status is cleanup_removing_project_namespaces' do let!(:cluster) { create(:cluster, :with_environments, :cleanup_removing_project_namespaces) } diff --git a/spec/workers/clusters/cleanup/service_account_worker_spec.rb b/spec/workers/clusters/cleanup/service_account_worker_spec.rb index 9af53dd63c1..dabc32a0ccd 100644 --- a/spec/workers/clusters/cleanup/service_account_worker_spec.rb +++ b/spec/workers/clusters/cleanup/service_account_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Clusters::Cleanup::ServiceAccountWorker do +RSpec.describe Clusters::Cleanup::ServiceAccountWorker do describe '#perform' do let!(:cluster) { create(:cluster, :cleanup_removing_service_account) } diff --git a/spec/workers/concerns/application_worker_spec.rb b/spec/workers/concerns/application_worker_spec.rb index 087a36d2bd0..a18b83f199b 100644 --- a/spec/workers/concerns/application_worker_spec.rb +++ b/spec/workers/concerns/application_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ApplicationWorker do +RSpec.describe ApplicationWorker do let_it_be(:worker) do Class.new do def self.name diff --git a/spec/workers/concerns/cluster_queue_spec.rb b/spec/workers/concerns/cluster_queue_spec.rb index 732d55dfbde..c03ca9cea48 100644 --- a/spec/workers/concerns/cluster_queue_spec.rb +++ b/spec/workers/concerns/cluster_queue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ClusterQueue do +RSpec.describe ClusterQueue do let(:worker) do Class.new do def self.name diff --git a/spec/workers/concerns/cronjob_queue_spec.rb b/spec/workers/concerns/cronjob_queue_spec.rb index 0cea67bf116..d1ad5c65ea3 100644 --- a/spec/workers/concerns/cronjob_queue_spec.rb +++ b/spec/workers/concerns/cronjob_queue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe CronjobQueue do +RSpec.describe CronjobQueue do let(:worker) do Class.new do def self.name diff --git a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb index 51b685b5792..d0cbc6b35e2 100644 --- a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::ObjectImporter do +RSpec.describe Gitlab::GithubImport::ObjectImporter do let(:worker) do Class.new do def self.name diff --git a/spec/workers/concerns/gitlab/github_import/queue_spec.rb b/spec/workers/concerns/gitlab/github_import/queue_spec.rb index d262bc2e05c..beca221b593 100644 --- a/spec/workers/concerns/gitlab/github_import/queue_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/queue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::Queue do +RSpec.describe Gitlab::GithubImport::Queue do it 'sets the Sidekiq options for the worker' do worker = Class.new do def self.name diff --git a/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb b/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb index c4f6ddf9aca..09d64fe50bd 100644 --- a/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::ReschedulingMethods do +RSpec.describe Gitlab::GithubImport::ReschedulingMethods do let(:worker) do Class.new { include(Gitlab::GithubImport::ReschedulingMethods) }.new end diff --git a/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb b/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb index f9081a875b5..b7635748498 100644 --- a/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::StageMethods do +RSpec.describe Gitlab::GithubImport::StageMethods do let(:project) { create(:project) } let(:worker) do Class.new { include(Gitlab::GithubImport::StageMethods) }.new diff --git a/spec/workers/concerns/gitlab/notify_upon_death_spec.rb b/spec/workers/concerns/gitlab/notify_upon_death_spec.rb index 1c75ac99227..dd0a1cadc9c 100644 --- a/spec/workers/concerns/gitlab/notify_upon_death_spec.rb +++ b/spec/workers/concerns/gitlab/notify_upon_death_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::NotifyUponDeath do +RSpec.describe Gitlab::NotifyUponDeath do let(:worker_class) do Class.new do include Sidekiq::Worker diff --git a/spec/workers/concerns/pipeline_background_queue_spec.rb b/spec/workers/concerns/pipeline_background_queue_spec.rb index 78ceafb359f..77c7e7440c5 100644 --- a/spec/workers/concerns/pipeline_background_queue_spec.rb +++ b/spec/workers/concerns/pipeline_background_queue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PipelineBackgroundQueue do +RSpec.describe PipelineBackgroundQueue do let(:worker) do Class.new do def self.name diff --git a/spec/workers/concerns/pipeline_queue_spec.rb b/spec/workers/concerns/pipeline_queue_spec.rb index eedfceb8bf0..6c1ac2052e4 100644 --- a/spec/workers/concerns/pipeline_queue_spec.rb +++ b/spec/workers/concerns/pipeline_queue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PipelineQueue do +RSpec.describe PipelineQueue do let(:worker) do Class.new do def self.name diff --git a/spec/workers/concerns/project_export_options_spec.rb b/spec/workers/concerns/project_export_options_spec.rb deleted file mode 100644 index 985afaaf11e..00000000000 --- a/spec/workers/concerns/project_export_options_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe ProjectExportOptions do - let(:project) { create(:project) } - let(:project_export_job) { create(:project_export_job, project: project, jid: '123', status: 1) } - let(:job) { { 'args' => [project.owner.id, project.id, nil, nil], 'jid' => '123' } } - let(:worker_class) do - Class.new do - include Sidekiq::Worker - include ProjectExportOptions - end - end - - it 'sets default retry limit' do - expect(worker_class.sidekiq_options['retry']).to eq(ProjectExportOptions::EXPORT_RETRY_COUNT) - end - - it 'sets default status expiration' do - expect(worker_class.sidekiq_options['status_expiration']).to eq(StuckExportJobsWorker::EXPORT_JOBS_EXPIRATION) - end - - describe '.sidekiq_retries_exhausted' do - it 'marks status as failed' do - expect { worker_class.sidekiq_retries_exhausted_block.call(job) }.to change { project_export_job.reload.status }.from(1).to(3) - end - - context 'when status update fails' do - before do - project_export_job.update(status: 2) - end - - it 'logs an error' do - expect(Sidekiq.logger).to receive(:error).with("Failed to set Job #{job['jid']} for project #{project.id} to failed state") - - worker_class.sidekiq_retries_exhausted_block.call(job) - end - end - end -end diff --git a/spec/workers/concerns/project_import_options_spec.rb b/spec/workers/concerns/project_import_options_spec.rb index c56dcc5ed82..85a26ddb0cb 100644 --- a/spec/workers/concerns/project_import_options_spec.rb +++ b/spec/workers/concerns/project_import_options_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ProjectImportOptions do +RSpec.describe ProjectImportOptions do let(:project) { create(:project, :import_started) } let(:job) { { 'args' => [project.id, nil, nil], 'jid' => '123' } } let(:worker_class) do diff --git a/spec/workers/concerns/reenqueuer_spec.rb b/spec/workers/concerns/reenqueuer_spec.rb index b28f83d211b..df0724045c1 100644 --- a/spec/workers/concerns/reenqueuer_spec.rb +++ b/spec/workers/concerns/reenqueuer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Reenqueuer do +RSpec.describe Reenqueuer do include ExclusiveLeaseHelpers let_it_be(:worker_class) do @@ -93,7 +93,7 @@ describe Reenqueuer do end end -describe Reenqueuer::ReenqueuerSleeper do +RSpec.describe Reenqueuer::ReenqueuerSleeper do let_it_be(:dummy_class) do Class.new do include Reenqueuer::ReenqueuerSleeper diff --git a/spec/workers/concerns/repository_check_queue_spec.rb b/spec/workers/concerns/repository_check_queue_spec.rb index 55ed71f124c..ae377c09b37 100644 --- a/spec/workers/concerns/repository_check_queue_spec.rb +++ b/spec/workers/concerns/repository_check_queue_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RepositoryCheckQueue do +RSpec.describe RepositoryCheckQueue do let(:worker) do Class.new do def self.name diff --git a/spec/workers/concerns/waitable_worker_spec.rb b/spec/workers/concerns/waitable_worker_spec.rb index e7ef96c685d..5d08d38380a 100644 --- a/spec/workers/concerns/waitable_worker_spec.rb +++ b/spec/workers/concerns/waitable_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe WaitableWorker do +RSpec.describe WaitableWorker do let(:worker) do Class.new do def self.name diff --git a/spec/workers/concerns/worker_context_spec.rb b/spec/workers/concerns/worker_context_spec.rb index 4e8c81c57dc..3de37b99aba 100644 --- a/spec/workers/concerns/worker_context_spec.rb +++ b/spec/workers/concerns/worker_context_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe WorkerContext do +RSpec.describe WorkerContext do let(:worker) do Class.new do def self.name diff --git a/spec/workers/container_expiration_policy_worker_spec.rb b/spec/workers/container_expiration_policy_worker_spec.rb index b15a28dcdca..868eb6b192e 100644 --- a/spec/workers/container_expiration_policy_worker_spec.rb +++ b/spec/workers/container_expiration_policy_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ContainerExpirationPolicyWorker do +RSpec.describe ContainerExpirationPolicyWorker do include ExclusiveLeaseHelpers subject { described_class.new.perform } diff --git a/spec/workers/create_commit_signature_worker_spec.rb b/spec/workers/create_commit_signature_worker_spec.rb index fd5d99b3265..d283ff5b732 100644 --- a/spec/workers/create_commit_signature_worker_spec.rb +++ b/spec/workers/create_commit_signature_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe CreateCommitSignatureWorker do +RSpec.describe CreateCommitSignatureWorker do let(:project) { create(:project, :repository) } let(:commits) { project.repository.commits('HEAD', limit: 3).commits } let(:commit_shas) { commits.map(&:id) } diff --git a/spec/workers/create_evidence_worker_spec.rb b/spec/workers/create_evidence_worker_spec.rb index b8c622f7d1d..c700c086163 100644 --- a/spec/workers/create_evidence_worker_spec.rb +++ b/spec/workers/create_evidence_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe CreateEvidenceWorker do +RSpec.describe CreateEvidenceWorker do let(:project) { create(:project, :repository) } let(:release) { create(:release, project: project) } let(:pipeline) { create(:ci_empty_pipeline, sha: release.sha, project: project) } diff --git a/spec/workers/create_note_diff_file_worker_spec.rb b/spec/workers/create_note_diff_file_worker_spec.rb index e35aaa7d593..4c1df8ade06 100644 --- a/spec/workers/create_note_diff_file_worker_spec.rb +++ b/spec/workers/create_note_diff_file_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe CreateNoteDiffFileWorker do +RSpec.describe CreateNoteDiffFileWorker do describe '#perform' do let(:diff_note) { create(:diff_note_on_merge_request) } diff --git a/spec/workers/create_pipeline_worker_spec.rb b/spec/workers/create_pipeline_worker_spec.rb index 62a17da80c0..6a3729fa28a 100644 --- a/spec/workers/create_pipeline_worker_spec.rb +++ b/spec/workers/create_pipeline_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe CreatePipelineWorker do +RSpec.describe CreatePipelineWorker do describe '#perform' do let(:worker) { described_class.new } diff --git a/spec/workers/delete_container_repository_worker_spec.rb b/spec/workers/delete_container_repository_worker_spec.rb index 8c40611a959..b8363a2f81a 100644 --- a/spec/workers/delete_container_repository_worker_spec.rb +++ b/spec/workers/delete_container_repository_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe DeleteContainerRepositoryWorker do +RSpec.describe DeleteContainerRepositoryWorker do let(:registry) { create(:container_repository) } let(:project) { registry.project } let(:user) { project.owner } diff --git a/spec/workers/delete_diff_files_worker_spec.rb b/spec/workers/delete_diff_files_worker_spec.rb index 9f8b20df48e..b3b01588e0b 100644 --- a/spec/workers/delete_diff_files_worker_spec.rb +++ b/spec/workers/delete_diff_files_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe DeleteDiffFilesWorker do +RSpec.describe DeleteDiffFilesWorker do describe '#perform' do let(:merge_request) { create(:merge_request) } let(:merge_request_diff) { merge_request.merge_request_diff } diff --git a/spec/workers/delete_merged_branches_worker_spec.rb b/spec/workers/delete_merged_branches_worker_spec.rb index 3eaeb7e0797..861ca111b92 100644 --- a/spec/workers/delete_merged_branches_worker_spec.rb +++ b/spec/workers/delete_merged_branches_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe DeleteMergedBranchesWorker do +RSpec.describe DeleteMergedBranchesWorker do subject(:worker) { described_class.new } let(:project) { create(:project, :repository) } diff --git a/spec/workers/delete_user_worker_spec.rb b/spec/workers/delete_user_worker_spec.rb index c963b886e62..52f2c692b8c 100644 --- a/spec/workers/delete_user_worker_spec.rb +++ b/spec/workers/delete_user_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe DeleteUserWorker do +RSpec.describe DeleteUserWorker do let!(:user) { create(:user) } let!(:current_user) { create(:user) } diff --git a/spec/workers/deployments/finished_worker_spec.rb b/spec/workers/deployments/finished_worker_spec.rb index 2961ff599c3..9b4bd78c03a 100644 --- a/spec/workers/deployments/finished_worker_spec.rb +++ b/spec/workers/deployments/finished_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Deployments::FinishedWorker do +RSpec.describe Deployments::FinishedWorker do let(:worker) { described_class.new } describe '#perform' do diff --git a/spec/workers/deployments/success_worker_spec.rb b/spec/workers/deployments/success_worker_spec.rb index 7f2816d7535..7c21a3147a7 100644 --- a/spec/workers/deployments/success_worker_spec.rb +++ b/spec/workers/deployments/success_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Deployments::SuccessWorker do +RSpec.describe Deployments::SuccessWorker do subject { described_class.new.perform(deployment&.id) } context 'when successful deployment' do diff --git a/spec/workers/design_management/new_version_worker_spec.rb b/spec/workers/design_management/new_version_worker_spec.rb index ef7cd8de108..4d57c46487e 100644 --- a/spec/workers/design_management/new_version_worker_spec.rb +++ b/spec/workers/design_management/new_version_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe DesignManagement::NewVersionWorker do +RSpec.describe DesignManagement::NewVersionWorker do describe '#perform' do let(:worker) { described_class.new } diff --git a/spec/workers/detect_repository_languages_worker_spec.rb b/spec/workers/detect_repository_languages_worker_spec.rb index 84af49050d4..217e16bd155 100644 --- a/spec/workers/detect_repository_languages_worker_spec.rb +++ b/spec/workers/detect_repository_languages_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe DetectRepositoryLanguagesWorker do +RSpec.describe DetectRepositoryLanguagesWorker do let_it_be(:project) { create(:project) } subject { described_class.new } diff --git a/spec/workers/email_receiver_worker_spec.rb b/spec/workers/email_receiver_worker_spec.rb index f8a31fcdee6..8bf7f3f552d 100644 --- a/spec/workers/email_receiver_worker_spec.rb +++ b/spec/workers/email_receiver_worker_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe EmailReceiverWorker, :mailer do +RSpec.describe EmailReceiverWorker, :mailer do let(:raw_message) { fixture_file('emails/valid_reply.eml') } context "when reply by email is enabled" do diff --git a/spec/workers/emails_on_push_worker_spec.rb b/spec/workers/emails_on_push_worker_spec.rb index 0f87df89c29..fac463b4dd4 100644 --- a/spec/workers/emails_on_push_worker_spec.rb +++ b/spec/workers/emails_on_push_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe EmailsOnPushWorker, :mailer do +RSpec.describe EmailsOnPushWorker, :mailer do include RepoHelpers include EmailSpec::Matchers diff --git a/spec/workers/environments/auto_stop_cron_worker_spec.rb b/spec/workers/environments/auto_stop_cron_worker_spec.rb index 6773637d4a7..1e86597d288 100644 --- a/spec/workers/environments/auto_stop_cron_worker_spec.rb +++ b/spec/workers/environments/auto_stop_cron_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Environments::AutoStopCronWorker do +RSpec.describe Environments::AutoStopCronWorker do subject { worker.perform } let(:worker) { described_class.new } diff --git a/spec/workers/error_tracking_issue_link_worker_spec.rb b/spec/workers/error_tracking_issue_link_worker_spec.rb index 701d54b72f0..5be568c2dad 100644 --- a/spec/workers/error_tracking_issue_link_worker_spec.rb +++ b/spec/workers/error_tracking_issue_link_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ErrorTrackingIssueLinkWorker do +RSpec.describe ErrorTrackingIssueLinkWorker do let_it_be(:error_tracking) { create(:project_error_tracking_setting) } let_it_be(:project) { error_tracking.project } let_it_be(:issue) { create(:issue, project: project) } diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb index 195783c74df..3bb9db07ff3 100644 --- a/spec/workers/every_sidekiq_worker_spec.rb +++ b/spec/workers/every_sidekiq_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Every Sidekiq worker' do +RSpec.describe 'Every Sidekiq worker' do let(:workers_without_defaults) do Gitlab::SidekiqConfig.workers - Gitlab::SidekiqConfig::DEFAULT_WORKERS end @@ -19,7 +19,7 @@ describe 'Every Sidekiq worker' do file_worker_queues = Gitlab::SidekiqConfig.worker_queues.to_set worker_queues = Gitlab::SidekiqConfig.workers.map(&:queue).to_set - worker_queues << ActionMailer::DeliveryJob.new.queue_name + worker_queues << ActionMailer::MailDeliveryJob.new.queue_name worker_queues << 'default' missing_from_file = worker_queues - file_worker_queues @@ -53,7 +53,7 @@ describe 'Every Sidekiq worker' do # All Sidekiq worker classes should declare a valid `feature_category` # or explicitly be excluded with the `feature_category_not_owned!` annotation. - # Please see doc/development/sidekiq_style_guide.md#Feature-Categorization for more details. + # Please see doc/development/sidekiq_style_guide.md#feature-categorization for more details. it 'has a feature_category or feature_category_not_owned! attribute', :aggregate_failures do workers_without_defaults.each do |worker| expect(worker.get_feature_category).to be_a(Symbol), "expected #{worker.inspect} to declare a feature_category or feature_category_not_owned!" @@ -62,7 +62,7 @@ describe 'Every Sidekiq worker' do # All Sidekiq worker classes should declare a valid `feature_category`. # The category should match a value in `config/feature_categories.yml`. - # Please see doc/development/sidekiq_style_guide.md#Feature-Categorization for more details. + # Please see doc/development/sidekiq_style_guide.md#feature-categorization for more details. it 'has a feature_category that maps to a value in feature_categories.yml', :aggregate_failures do workers_with_feature_categories = workers_without_defaults .select(&:get_feature_category) diff --git a/spec/workers/expire_build_artifacts_worker_spec.rb b/spec/workers/expire_build_artifacts_worker_spec.rb index 06561e94fb7..995f37daf17 100644 --- a/spec/workers/expire_build_artifacts_worker_spec.rb +++ b/spec/workers/expire_build_artifacts_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ExpireBuildArtifactsWorker do +RSpec.describe ExpireBuildArtifactsWorker do let(:worker) { described_class.new } describe '#perform' do diff --git a/spec/workers/expire_build_instance_artifacts_worker_spec.rb b/spec/workers/expire_build_instance_artifacts_worker_spec.rb index 335fa5e6c98..38318447b5f 100644 --- a/spec/workers/expire_build_instance_artifacts_worker_spec.rb +++ b/spec/workers/expire_build_instance_artifacts_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ExpireBuildInstanceArtifactsWorker do +RSpec.describe ExpireBuildInstanceArtifactsWorker do include RepoHelpers let(:worker) { described_class.new } @@ -32,7 +32,7 @@ describe ExpireBuildInstanceArtifactsWorker do context 'with not yet expired artifacts' do let_it_be(:build) do - create(:ci_build, :artifacts, artifacts_expire_at: Time.now + 7.days) + create(:ci_build, :artifacts, artifacts_expire_at: Time.current + 7.days) end it 'does not expire' do diff --git a/spec/workers/expire_job_cache_worker_spec.rb b/spec/workers/expire_job_cache_worker_spec.rb index 062926cf7aa..b4f8f56563b 100644 --- a/spec/workers/expire_job_cache_worker_spec.rb +++ b/spec/workers/expire_job_cache_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ExpireJobCacheWorker do +RSpec.describe ExpireJobCacheWorker do let_it_be(:pipeline) { create(:ci_empty_pipeline) } let(:project) { pipeline.project } diff --git a/spec/workers/expire_pipeline_cache_worker_spec.rb b/spec/workers/expire_pipeline_cache_worker_spec.rb index 61ea22fbd32..fb6ee67311c 100644 --- a/spec/workers/expire_pipeline_cache_worker_spec.rb +++ b/spec/workers/expire_pipeline_cache_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ExpirePipelineCacheWorker do +RSpec.describe ExpirePipelineCacheWorker do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } let_it_be(:pipeline) { create(:ci_pipeline, project: project) } diff --git a/spec/workers/export_csv_worker_spec.rb b/spec/workers/export_csv_worker_spec.rb index 87285b6264a..1a5b17ee35b 100644 --- a/spec/workers/export_csv_worker_spec.rb +++ b/spec/workers/export_csv_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ExportCsvWorker do +RSpec.describe ExportCsvWorker do let(:user) { create(:user) } let(:project) { create(:project, creator: user) } diff --git a/spec/workers/external_service_reactive_caching_worker_spec.rb b/spec/workers/external_service_reactive_caching_worker_spec.rb index 45cce71b75b..907894d9b9a 100644 --- a/spec/workers/external_service_reactive_caching_worker_spec.rb +++ b/spec/workers/external_service_reactive_caching_worker_spec.rb @@ -2,6 +2,6 @@ require 'spec_helper' -describe ExternalServiceReactiveCachingWorker do +RSpec.describe ExternalServiceReactiveCachingWorker do it_behaves_like 'reactive cacheable worker' end diff --git a/spec/workers/file_hook_worker_spec.rb b/spec/workers/file_hook_worker_spec.rb index 1a7e753fc4a..c171dc37e5f 100644 --- a/spec/workers/file_hook_worker_spec.rb +++ b/spec/workers/file_hook_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe FileHookWorker do +RSpec.describe FileHookWorker do include RepoHelpers let(:filename) { 'my_file_hook.rb' } diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb index 64ad4ba7eb6..cb6396e2859 100644 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ b/spec/workers/git_garbage_collect_worker_spec.rb @@ -4,7 +4,7 @@ require 'fileutils' require 'spec_helper' -describe GitGarbageCollectWorker do +RSpec.describe GitGarbageCollectWorker do include GitHelpers let(:project) { create(:project, :repository) } diff --git a/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb b/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb index b1647d8c7df..4e8261f61c4 100644 --- a/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb +++ b/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_state do +RSpec.describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_state do let(:project) { create(:project) } let(:import_state) { create(:import_state, project: project, jid: '123') } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb b/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb index 42d69ff6166..211eba993f7 100644 --- a/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb +++ b/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::ImportDiffNoteWorker do +RSpec.describe Gitlab::GithubImport::ImportDiffNoteWorker do let(:worker) { described_class.new } describe '#import' do diff --git a/spec/workers/gitlab/github_import/import_issue_worker_spec.rb b/spec/workers/gitlab/github_import/import_issue_worker_spec.rb index 06a573e16b7..1d285790ee2 100644 --- a/spec/workers/gitlab/github_import/import_issue_worker_spec.rb +++ b/spec/workers/gitlab/github_import/import_issue_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::ImportIssueWorker do +RSpec.describe Gitlab::GithubImport::ImportIssueWorker do let(:worker) { described_class.new } describe '#import' do diff --git a/spec/workers/gitlab/github_import/import_note_worker_spec.rb b/spec/workers/gitlab/github_import/import_note_worker_spec.rb index 5110c3ff11b..618aca4ff0a 100644 --- a/spec/workers/gitlab/github_import/import_note_worker_spec.rb +++ b/spec/workers/gitlab/github_import/import_note_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::ImportNoteWorker do +RSpec.describe Gitlab::GithubImport::ImportNoteWorker do let(:worker) { described_class.new } describe '#import' do diff --git a/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb b/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb index d46e381fc51..0f5df302d56 100644 --- a/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb +++ b/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::ImportPullRequestWorker do +RSpec.describe Gitlab::GithubImport::ImportPullRequestWorker do let(:worker) { described_class.new } describe '#import' do diff --git a/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb b/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb index fa4ded8e42f..3a8b585fa77 100644 --- a/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb +++ b/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::RefreshImportJidWorker do +RSpec.describe Gitlab::GithubImport::RefreshImportJidWorker do let(:worker) { described_class.new } describe '.perform_in_the_future' do diff --git a/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb b/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb index 35a856802c2..c821e0aaa09 100644 --- a/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::Stage::FinishImportWorker do +RSpec.describe Gitlab::GithubImport::Stage::FinishImportWorker do let(:project) { create(:project) } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb index 0c7fc2a164e..f68d0838501 100644 --- a/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::Stage::ImportBaseDataWorker do +RSpec.describe Gitlab::GithubImport::Stage::ImportBaseDataWorker do let(:project) { create(:project) } let(:import_state) { create(:import_state, project: project) } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb index 5d96f562c30..f2a28ec40b8 100644 --- a/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do +RSpec.describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do let(:project) { create(:project) } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb index e7c9dabb292..103d55890c4 100644 --- a/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::Stage::ImportLfsObjectsWorker do +RSpec.describe Gitlab::GithubImport::Stage::ImportLfsObjectsWorker do let(:project) { create(:project) } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb index 90590a45900..73b19239f4a 100644 --- a/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::Stage::ImportNotesWorker do +RSpec.describe Gitlab::GithubImport::Stage::ImportNotesWorker do let(:project) { create(:project) } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb index 15d485f1018..0acbca7032c 100644 --- a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker do +RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker do let(:project) { create(:project) } let(:import_state) { create(:import_state, project: project) } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb index 3a8fe73622a..bc51a44e057 100644 --- a/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do +RSpec.describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do let(:project) { double(:project, id: 4) } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/import/stuck_project_import_jobs_worker_spec.rb b/spec/workers/gitlab/import/stuck_project_import_jobs_worker_spec.rb index 5afc5717b82..510c41cba21 100644 --- a/spec/workers/gitlab/import/stuck_project_import_jobs_worker_spec.rb +++ b/spec/workers/gitlab/import/stuck_project_import_jobs_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Import::StuckProjectImportJobsWorker do +RSpec.describe Gitlab::Import::StuckProjectImportJobsWorker do let(:worker) { described_class.new } describe 'with scheduled import_status' do diff --git a/spec/workers/gitlab/jira_import/import_issue_worker_spec.rb b/spec/workers/gitlab/jira_import/import_issue_worker_spec.rb index 2de609761e2..4a4ef5700fa 100644 --- a/spec/workers/gitlab/jira_import/import_issue_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/import_issue_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::JiraImport::ImportIssueWorker do +RSpec.describe Gitlab::JiraImport::ImportIssueWorker do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } let_it_be(:jira_issue_label_1) { create(:label, project: project) } diff --git a/spec/workers/gitlab/jira_import/stage/finish_import_worker_spec.rb b/spec/workers/gitlab/jira_import/stage/finish_import_worker_spec.rb index 084302be7d8..23a764bd972 100644 --- a/spec/workers/gitlab/jira_import/stage/finish_import_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/stage/finish_import_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::JiraImport::Stage::FinishImportWorker do +RSpec.describe Gitlab::JiraImport::Stage::FinishImportWorker do let_it_be(:project) { create(:project) } let_it_be(:worker) { described_class.new } diff --git a/spec/workers/gitlab/jira_import/stage/import_attachments_worker_spec.rb b/spec/workers/gitlab/jira_import/stage/import_attachments_worker_spec.rb index 34981d974cd..28da93b8d00 100644 --- a/spec/workers/gitlab/jira_import/stage/import_attachments_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/stage/import_attachments_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::JiraImport::Stage::ImportAttachmentsWorker do +RSpec.describe Gitlab::JiraImport::Stage::ImportAttachmentsWorker do let_it_be(:project) { create(:project, import_type: 'jira') } describe 'modules' do diff --git a/spec/workers/gitlab/jira_import/stage/import_issues_worker_spec.rb b/spec/workers/gitlab/jira_import/stage/import_issues_worker_spec.rb index 40f6cf75412..f82f6ccd9d6 100644 --- a/spec/workers/gitlab/jira_import/stage/import_issues_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/stage/import_issues_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::JiraImport::Stage::ImportIssuesWorker do +RSpec.describe Gitlab::JiraImport::Stage::ImportIssuesWorker do include JiraServiceHelper let_it_be(:user) { create(:user) } diff --git a/spec/workers/gitlab/jira_import/stage/import_labels_worker_spec.rb b/spec/workers/gitlab/jira_import/stage/import_labels_worker_spec.rb index 1215b41bd9f..0b7a35a92e2 100644 --- a/spec/workers/gitlab/jira_import/stage/import_labels_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/stage/import_labels_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::JiraImport::Stage::ImportLabelsWorker do +RSpec.describe Gitlab::JiraImport::Stage::ImportLabelsWorker do include JiraServiceHelper let_it_be(:user) { create(:user) } diff --git a/spec/workers/gitlab/jira_import/stage/import_notes_worker_spec.rb b/spec/workers/gitlab/jira_import/stage/import_notes_worker_spec.rb index a0a9ad6f695..2502bbf1df4 100644 --- a/spec/workers/gitlab/jira_import/stage/import_notes_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/stage/import_notes_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::JiraImport::Stage::ImportNotesWorker do +RSpec.describe Gitlab::JiraImport::Stage::ImportNotesWorker do let_it_be(:project) { create(:project, import_type: 'jira') } describe 'modules' do diff --git a/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb b/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb index a4fc761accf..7066e6e912f 100644 --- a/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::JiraImport::Stage::StartImportWorker do +RSpec.describe Gitlab::JiraImport::Stage::StartImportWorker do let_it_be(:project) { create(:project, import_type: 'jira') } let_it_be(:jid) { '12345678' } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/jira_import/stuck_jira_import_jobs_worker_spec.rb b/spec/workers/gitlab/jira_import/stuck_jira_import_jobs_worker_spec.rb index fae52cec2b4..8271af4db2f 100644 --- a/spec/workers/gitlab/jira_import/stuck_jira_import_jobs_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/stuck_jira_import_jobs_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do +RSpec.describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project) } let(:worker) { described_class.new } diff --git a/spec/workers/gitlab/phabricator_import/base_worker_spec.rb b/spec/workers/gitlab/phabricator_import/base_worker_spec.rb index d46d908a3e3..18fa484aa7a 100644 --- a/spec/workers/gitlab/phabricator_import/base_worker_spec.rb +++ b/spec/workers/gitlab/phabricator_import/base_worker_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe Gitlab::PhabricatorImport::BaseWorker do +RSpec.describe Gitlab::PhabricatorImport::BaseWorker do let(:subclass) do # Creating an anonymous class for a worker is complicated, as we generate the # queue name from the class name. diff --git a/spec/workers/gitlab/phabricator_import/import_tasks_worker_spec.rb b/spec/workers/gitlab/phabricator_import/import_tasks_worker_spec.rb index 1e38ef8aaa5..221b6202166 100644 --- a/spec/workers/gitlab/phabricator_import/import_tasks_worker_spec.rb +++ b/spec/workers/gitlab/phabricator_import/import_tasks_worker_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe Gitlab::PhabricatorImport::ImportTasksWorker do +RSpec.describe Gitlab::PhabricatorImport::ImportTasksWorker do describe '#perform' do it 'calls the correct importer' do project = create(:project, :import_started, import_url: "https://the.phab.ulr") diff --git a/spec/workers/gitlab_shell_worker_spec.rb b/spec/workers/gitlab_shell_worker_spec.rb index 0e63f48d3e8..c46ef87333a 100644 --- a/spec/workers/gitlab_shell_worker_spec.rb +++ b/spec/workers/gitlab_shell_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabShellWorker do +RSpec.describe GitlabShellWorker do let(:worker) { described_class.new } describe '#perform' do diff --git a/spec/workers/gitlab_usage_ping_worker_spec.rb b/spec/workers/gitlab_usage_ping_worker_spec.rb index 198daf40493..05d6f2e585b 100644 --- a/spec/workers/gitlab_usage_ping_worker_spec.rb +++ b/spec/workers/gitlab_usage_ping_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GitlabUsagePingWorker do +RSpec.describe GitlabUsagePingWorker do subject { described_class.new } it 'delegates to SubmitUsagePingService' do diff --git a/spec/workers/group_destroy_worker_spec.rb b/spec/workers/group_destroy_worker_spec.rb index 90a4150a31a..ab3dd19dec1 100644 --- a/spec/workers/group_destroy_worker_spec.rb +++ b/spec/workers/group_destroy_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GroupDestroyWorker do +RSpec.describe GroupDestroyWorker do let(:group) { create(:group) } let(:user) { create(:admin) } let!(:project) { create(:project, namespace: group) } diff --git a/spec/workers/group_export_worker_spec.rb b/spec/workers/group_export_worker_spec.rb index 350777df912..5697e66b7d1 100644 --- a/spec/workers/group_export_worker_spec.rb +++ b/spec/workers/group_export_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GroupExportWorker do +RSpec.describe GroupExportWorker do let!(:user) { create(:user) } let!(:group) { create(:group) } diff --git a/spec/workers/group_import_worker_spec.rb b/spec/workers/group_import_worker_spec.rb index 324a5fa6978..fb2d49c21af 100644 --- a/spec/workers/group_import_worker_spec.rb +++ b/spec/workers/group_import_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe GroupImportWorker do +RSpec.describe GroupImportWorker do let!(:user) { create(:user) } let!(:group) { create(:group) } diff --git a/spec/workers/hashed_storage/migrator_worker_spec.rb b/spec/workers/hashed_storage/migrator_worker_spec.rb index ac76a306f43..e014297756e 100644 --- a/spec/workers/hashed_storage/migrator_worker_spec.rb +++ b/spec/workers/hashed_storage/migrator_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe HashedStorage::MigratorWorker do +RSpec.describe HashedStorage::MigratorWorker do subject(:worker) { described_class.new } let(:projects) { create_list(:project, 2, :legacy_storage, :empty_repo) } diff --git a/spec/workers/hashed_storage/project_migrate_worker_spec.rb b/spec/workers/hashed_storage/project_migrate_worker_spec.rb index 4b1b5f84fd3..fd460888932 100644 --- a/spec/workers/hashed_storage/project_migrate_worker_spec.rb +++ b/spec/workers/hashed_storage/project_migrate_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe HashedStorage::ProjectMigrateWorker, :clean_gitlab_redis_shared_state do +RSpec.describe HashedStorage::ProjectMigrateWorker, :clean_gitlab_redis_shared_state do include ExclusiveLeaseHelpers let(:migration_service) { ::Projects::HashedStorage::MigrationService } diff --git a/spec/workers/hashed_storage/project_rollback_worker_spec.rb b/spec/workers/hashed_storage/project_rollback_worker_spec.rb index d833553c0ec..fc89ac728b1 100644 --- a/spec/workers/hashed_storage/project_rollback_worker_spec.rb +++ b/spec/workers/hashed_storage/project_rollback_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe HashedStorage::ProjectRollbackWorker, :clean_gitlab_redis_shared_state do +RSpec.describe HashedStorage::ProjectRollbackWorker, :clean_gitlab_redis_shared_state do include ExclusiveLeaseHelpers describe '#perform' do diff --git a/spec/workers/hashed_storage/rollbacker_worker_spec.rb b/spec/workers/hashed_storage/rollbacker_worker_spec.rb index 55fc4fb0fe1..46cca068273 100644 --- a/spec/workers/hashed_storage/rollbacker_worker_spec.rb +++ b/spec/workers/hashed_storage/rollbacker_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe HashedStorage::RollbackerWorker do +RSpec.describe HashedStorage::RollbackerWorker do subject(:worker) { described_class.new } let(:projects) { create_list(:project, 2, :empty_repo) } diff --git a/spec/workers/import_issues_csv_worker_spec.rb b/spec/workers/import_issues_csv_worker_spec.rb index 03944cfb05d..c5420b00e8a 100644 --- a/spec/workers/import_issues_csv_worker_spec.rb +++ b/spec/workers/import_issues_csv_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ImportIssuesCsvWorker do +RSpec.describe ImportIssuesCsvWorker do let(:project) { create(:project) } let(:user) { create(:user) } let(:upload) { create(:upload) } diff --git a/spec/workers/incident_management/pager_duty/process_incident_worker_spec.rb b/spec/workers/incident_management/pager_duty/process_incident_worker_spec.rb new file mode 100644 index 00000000000..e2be91516b9 --- /dev/null +++ b/spec/workers/incident_management/pager_duty/process_incident_worker_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe IncidentManagement::PagerDuty::ProcessIncidentWorker do + let_it_be(:project) { create(:project) } + let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: true) } + + describe '#perform' do + subject(:perform) { described_class.new.perform(project.id, incident_payload) } + + context 'with valid incident payload' do + let(:incident_payload) do + { + 'url' => 'https://webdemo.pagerduty.com/incidents/PRORDTY', + 'incident_number' => 33, + 'title' => 'My new incident', + 'status' => 'triggered', + 'created_at' => '2017-09-26T15:14:36Z', + 'urgency' => 'high', + 'incident_key' => nil, + 'assignees' => [{ + 'summary' => 'Laura Haley', 'url' => 'https://webdemo.pagerduty.com/users/P553OPV' + }], + 'impacted_services' => [{ + 'summary' => 'Production XDB Cluster', 'url' => 'https://webdemo.pagerduty.com/services/PN49J75' + }] + } + end + + it 'creates a GitLab issue' do + expect { perform }.to change(Issue, :count).by(1) + end + end + + context 'with invalid incident payload' do + let(:incident_payload) { {} } + + before do + allow(Gitlab::AppLogger).to receive(:warn).and_call_original + end + + it 'does not create a GitLab issue' do + expect { perform }.not_to change(Issue, :count) + end + + it 'logs a warning' do + perform + + expect(Gitlab::AppLogger).to have_received(:warn).with( + message: 'Cannot create issue for PagerDuty incident', + issue_errors: "Title can't be blank" + ) + end + end + end +end diff --git a/spec/workers/incident_management/process_alert_worker_spec.rb b/spec/workers/incident_management/process_alert_worker_spec.rb index 0470552d933..75696d15ab8 100644 --- a/spec/workers/incident_management/process_alert_worker_spec.rb +++ b/spec/workers/incident_management/process_alert_worker_spec.rb @@ -2,40 +2,36 @@ require 'spec_helper' -describe IncidentManagement::ProcessAlertWorker do +RSpec.describe IncidentManagement::ProcessAlertWorker do let_it_be(:project) { create(:project) } let_it_be(:settings) { create(:project_incident_management_setting, project: project, create_issue: true) } describe '#perform' do - let(:alert_management_alert_id) { nil } - let(:alert_payload) do - { - 'annotations' => { 'title' => 'title' }, - 'startsAt' => Time.now.rfc3339 - } - end - - let(:created_issue) { Issue.last } + let_it_be(:started_at) { Time.now.rfc3339 } + let_it_be(:payload) { { 'title' => 'title', 'start_time' => started_at } } + let_it_be(:parsed_payload) { Gitlab::Alerting::NotificationPayloadParser.call(payload, project) } + let_it_be(:alert) { create(:alert_management_alert, project: project, payload: payload, started_at: started_at) } + let(:created_issue) { Issue.last! } - subject { described_class.new.perform(project.id, alert_payload, alert_management_alert_id) } + subject { described_class.new.perform(nil, nil, alert.id) } before do allow(IncidentManagement::CreateIssueService) - .to receive(:new).with(project, alert_payload) + .to receive(:new).with(alert.project, parsed_payload) .and_call_original end it 'creates an issue' do expect(IncidentManagement::CreateIssueService) - .to receive(:new).with(project, alert_payload) + .to receive(:new).with(alert.project, parsed_payload) expect { subject }.to change { Issue.count }.by(1) end - context 'with invalid project' do - let(:invalid_project_id) { non_existing_record_id } + context 'with invalid alert' do + let(:invalid_alert_id) { non_existing_record_id } - subject { described_class.new.perform(invalid_project_id, alert_payload) } + subject { described_class.new.perform(nil, nil, invalid_alert_id) } it 'does not create issues' do expect(IncidentManagement::CreateIssueService).not_to receive(:new) @@ -44,16 +40,8 @@ describe IncidentManagement::ProcessAlertWorker do end end - context 'when alert_management_alert_id is present' do - let!(:alert) { create(:alert_management_alert, project: project) } - let(:alert_management_alert_id) { alert.id } - + context 'with valid alert' do before do - allow(AlertManagement::Alert) - .to receive(:find_by_id) - .with(alert_management_alert_id) - .and_return(alert) - allow(Gitlab::AppLogger).to receive(:warn).and_call_original end @@ -69,24 +57,24 @@ describe IncidentManagement::ProcessAlertWorker do expect(Gitlab::AppLogger).not_to have_received(:warn) end - end - context 'when alert cannot be updated' do - let(:alert) { create(:alert_management_alert, :with_validation_errors, project: project) } + context 'when alert cannot be updated' do + let_it_be(:alert) { create(:alert_management_alert, :with_validation_errors, project: project, payload: payload) } - it 'updates AlertManagement::Alert#issue_id' do - expect { subject }.not_to change { alert.reload.issue_id } - end + it 'updates AlertManagement::Alert#issue_id' do + expect { subject }.not_to change { alert.reload.issue_id } + end - it 'logs a warning' do - subject + it 'logs a warning' do + subject - expect(Gitlab::AppLogger).to have_received(:warn).with( - message: 'Cannot link an Issue with Alert', - issue_id: created_issue.id, - alert_id: alert_management_alert_id, - alert_errors: { hosts: ['hosts array is over 255 chars'] } - ) + expect(Gitlab::AppLogger).to have_received(:warn).with( + message: 'Cannot link an Issue with Alert', + issue_id: created_issue.id, + alert_id: alert.id, + alert_errors: { hosts: ['hosts array is over 255 chars'] } + ) + end end end end diff --git a/spec/workers/incident_management/process_prometheus_alert_worker_spec.rb b/spec/workers/incident_management/process_prometheus_alert_worker_spec.rb index c9ea96df5c2..c294892a66f 100644 --- a/spec/workers/incident_management/process_prometheus_alert_worker_spec.rb +++ b/spec/workers/incident_management/process_prometheus_alert_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe IncidentManagement::ProcessPrometheusAlertWorker do +RSpec.describe IncidentManagement::ProcessPrometheusAlertWorker do describe '#perform' do let_it_be(:project) { create(:project) } let_it_be(:prometheus_alert) { create(:prometheus_alert, project: project) } @@ -19,137 +19,9 @@ describe IncidentManagement::ProcessPrometheusAlertWorker do }.with_indifferent_access end - it 'creates an issue' do + it 'does nothing' do expect { subject.perform(project.id, alert_params) } - .to change(Issue, :count) - .by(1) - end - - it 'relates issue to an event' do - expect { subject.perform(project.id, alert_params) } - .to change(prometheus_alert.related_issues, :count) - .from(0) - .to(1) - end - - context 'resolved event' do - let(:issue) { create(:issue, project: project) } - - before do - prometheus_alert_event.related_issues << issue - prometheus_alert_event.resolve - end - - it 'does not create an issue' do - expect { subject.perform(project.id, alert_params) } - .not_to change(Issue, :count) - end - - it 'closes the existing issue' do - expect { subject.perform(project.id, alert_params) } - .to change { issue.reload.state } - .from('opened') - .to('closed') - end - - it 'leaves a system note on the issue' do - expect(SystemNoteService) - .to receive(:auto_resolve_prometheus_alert) - - subject.perform(project.id, alert_params) - end - end - - context 'when project could not be found' do - let(:non_existing_project_id) { non_existing_record_id } - - it 'does not create an issue' do - expect { subject.perform(non_existing_project_id, alert_params) } - .not_to change(Issue, :count) - end - - it 'does not relate issue to an event' do - expect { subject.perform(non_existing_project_id, alert_params) } - .not_to change(prometheus_alert.related_issues, :count) - end - end - - context 'when event could not be found' do - before do - alert_params[:labels][:gitlab_alert_id] = non_existing_record_id - end - - it 'does not create an issue' do - expect { subject.perform(project.id, alert_params) } - .not_to change(Issue, :count) - end - - it 'does not relate issue to an event' do - expect { subject.perform(project.id, alert_params) } - .not_to change(prometheus_alert.related_issues, :count) - end - end - - context 'when issue could not be created' do - before do - allow_next_instance_of(IncidentManagement::CreateIssueService) do |instance| - allow(instance).to receive(:execute).and_return( { error: true } ) - end - end - - it 'does not relate issue to an event' do - expect { subject.perform(project.id, alert_params) } - .not_to change(prometheus_alert.related_issues, :count) - end - end - - context 'self-managed alert' do - let(:alert_name) { 'alert' } - let(:starts_at) { Time.now.rfc3339 } - - let!(:prometheus_alert_event) do - create(:self_managed_prometheus_alert_event, project: project, payload_key: payload_key) - end - - let(:alert_params) do - { - startsAt: starts_at, - generatorURL: 'http://localhost:9090/graph?g0.expr=vector%281%29&g0.tab=1', - labels: { - alertname: alert_name - } - }.with_indifferent_access - end - - it 'creates an issue' do - expect { subject.perform(project.id, alert_params) } - .to change(Issue, :count) - .by(1) - end - - it 'relates issue to an event' do - expect { subject.perform(project.id, alert_params) } - .to change(prometheus_alert_event.related_issues, :count) - .from(0) - .to(1) - end - - context 'when event could not be found' do - before do - alert_params[:generatorURL] = 'http://somethingelse.com' - end - - it 'creates an issue' do - expect { subject.perform(project.id, alert_params) } - .to change(Issue, :count) - .by(1) - end - - it 'does not relate issue to an event' do - expect { subject.perform(project.id, alert_params) } - .not_to change(prometheus_alert.related_issues, :count) - end - end + .not_to change(Issue, :count) end end end diff --git a/spec/workers/invalid_gpg_signature_update_worker_spec.rb b/spec/workers/invalid_gpg_signature_update_worker_spec.rb index 4f727469ea8..25c48b55cbb 100644 --- a/spec/workers/invalid_gpg_signature_update_worker_spec.rb +++ b/spec/workers/invalid_gpg_signature_update_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe InvalidGpgSignatureUpdateWorker do +RSpec.describe InvalidGpgSignatureUpdateWorker do context 'when GpgKey is found' do it 'calls NotificationService.new.run' do gpg_key = create(:gpg_key) diff --git a/spec/workers/irker_worker_spec.rb b/spec/workers/irker_worker_spec.rb index 6b58c04d909..aa1f1d2fe1d 100644 --- a/spec/workers/irker_worker_spec.rb +++ b/spec/workers/irker_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe IrkerWorker, '#perform' do +RSpec.describe IrkerWorker, '#perform' do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } let_it_be(:push_data) { HashWithIndifferentAccess.new(Gitlab::DataBuilder::Push.build_sample(project, user)) } diff --git a/spec/workers/issue_due_scheduler_worker_spec.rb b/spec/workers/issue_due_scheduler_worker_spec.rb index 61ad8330840..aecff4a3d93 100644 --- a/spec/workers/issue_due_scheduler_worker_spec.rb +++ b/spec/workers/issue_due_scheduler_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe IssueDueSchedulerWorker do +RSpec.describe IssueDueSchedulerWorker do describe '#perform' do it 'schedules one MailScheduler::IssueDueWorker per project with open issues due tomorrow' do project1 = create(:project) diff --git a/spec/workers/mail_scheduler/issue_due_worker_spec.rb b/spec/workers/mail_scheduler/issue_due_worker_spec.rb index fa17775e9f2..c03cc0bda61 100644 --- a/spec/workers/mail_scheduler/issue_due_worker_spec.rb +++ b/spec/workers/mail_scheduler/issue_due_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe MailScheduler::IssueDueWorker do +RSpec.describe MailScheduler::IssueDueWorker do describe '#perform' do let(:worker) { described_class.new } let(:project) { create(:project) } diff --git a/spec/workers/mail_scheduler/notification_service_worker_spec.rb b/spec/workers/mail_scheduler/notification_service_worker_spec.rb index ac95a6d7e43..ff4a1646d09 100644 --- a/spec/workers/mail_scheduler/notification_service_worker_spec.rb +++ b/spec/workers/mail_scheduler/notification_service_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe MailScheduler::NotificationServiceWorker do +RSpec.describe MailScheduler::NotificationServiceWorker do let(:worker) { described_class.new } let(:method) { 'new_key' } diff --git a/spec/workers/members_destroyer/unassign_issuables_worker_spec.rb b/spec/workers/members_destroyer/unassign_issuables_worker_spec.rb new file mode 100644 index 00000000000..2a325be1225 --- /dev/null +++ b/spec/workers/members_destroyer/unassign_issuables_worker_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe MembersDestroyer::UnassignIssuablesWorker do + let_it_be(:group) { create(:group, :private) } + let_it_be(:user, reload: true) { create(:user) } + + context 'when unsupported membership source entity' do + it 'exits early and logs error' do + params = { message: "SomeEntity is not a supported entity.", entity_type: 'SomeEntity', entity_id: group.id, user_id: user.id } + + expect(Sidekiq.logger).to receive(:error).with(params) + + described_class.new.perform(user.id, group.id, 'SomeEntity') + end + end + + it "calls the Members::UnassignIssuablesService with the params it was given" do + service = double + + expect(Members::UnassignIssuablesService).to receive(:new).with(user, group).and_return(service) + expect(service).to receive(:execute) + + described_class.new.perform(user.id, group.id, 'Group') + end +end diff --git a/spec/workers/merge_request_mergeability_check_worker_spec.rb b/spec/workers/merge_request_mergeability_check_worker_spec.rb index 8909af1f685..0349de5cbb3 100644 --- a/spec/workers/merge_request_mergeability_check_worker_spec.rb +++ b/spec/workers/merge_request_mergeability_check_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe MergeRequestMergeabilityCheckWorker do +RSpec.describe MergeRequestMergeabilityCheckWorker do subject { described_class.new } describe '#perform' do diff --git a/spec/workers/merge_worker_spec.rb b/spec/workers/merge_worker_spec.rb index dc98c9836fa..97e8aeb616e 100644 --- a/spec/workers/merge_worker_spec.rb +++ b/spec/workers/merge_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe MergeWorker do +RSpec.describe MergeWorker do describe "remove source branch" do let!(:merge_request) { create(:merge_request, source_branch: "markdown") } let!(:source_project) { merge_request.source_project } diff --git a/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb b/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb index bab5a5d8740..d93612afe37 100644 --- a/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb +++ b/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Metrics::Dashboard::PruneOldAnnotationsWorker do +RSpec.describe Metrics::Dashboard::PruneOldAnnotationsWorker do let_it_be(:now) { DateTime.parse('2020-06-02T00:12:00Z') } let_it_be(:two_weeks_old_annotation) { create(:metrics_dashboard_annotation, starting_at: now.advance(weeks: -2)) } let_it_be(:one_day_old_annotation) { create(:metrics_dashboard_annotation, starting_at: now.advance(days: -1)) } diff --git a/spec/workers/metrics/dashboard/schedule_annotations_prune_worker_spec.rb b/spec/workers/metrics/dashboard/schedule_annotations_prune_worker_spec.rb index bfe6fe3a90e..e0a5a8fd448 100644 --- a/spec/workers/metrics/dashboard/schedule_annotations_prune_worker_spec.rb +++ b/spec/workers/metrics/dashboard/schedule_annotations_prune_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Metrics::Dashboard::ScheduleAnnotationsPruneWorker do +RSpec.describe Metrics::Dashboard::ScheduleAnnotationsPruneWorker do describe '#perform' do it 'schedules annotations prune job with default cut off date' do expect(Metrics::Dashboard::PruneOldAnnotationsWorker).to receive(:perform_async) diff --git a/spec/workers/migrate_external_diffs_worker_spec.rb b/spec/workers/migrate_external_diffs_worker_spec.rb index 88d48cad14b..86d4680acbe 100644 --- a/spec/workers/migrate_external_diffs_worker_spec.rb +++ b/spec/workers/migrate_external_diffs_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe MigrateExternalDiffsWorker do +RSpec.describe MigrateExternalDiffsWorker do let(:worker) { described_class.new } let(:diff) { create(:merge_request).merge_request_diff } diff --git a/spec/workers/namespaceless_project_destroy_worker_spec.rb b/spec/workers/namespaceless_project_destroy_worker_spec.rb index ceea7c8d8f5..ef396bc7fbb 100644 --- a/spec/workers/namespaceless_project_destroy_worker_spec.rb +++ b/spec/workers/namespaceless_project_destroy_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe NamespacelessProjectDestroyWorker do +RSpec.describe NamespacelessProjectDestroyWorker do include ProjectForksHelper subject { described_class.new } diff --git a/spec/workers/namespaces/prune_aggregation_schedules_worker_spec.rb b/spec/workers/namespaces/prune_aggregation_schedules_worker_spec.rb index b069b080531..11f2501cbe3 100644 --- a/spec/workers/namespaces/prune_aggregation_schedules_worker_spec.rb +++ b/spec/workers/namespaces/prune_aggregation_schedules_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Namespaces::PruneAggregationSchedulesWorker, '#perform', :clean_gitlab_redis_shared_state do +RSpec.describe Namespaces::PruneAggregationSchedulesWorker, '#perform', :clean_gitlab_redis_shared_state do include ExclusiveLeaseHelpers let(:namespaces) { create_list(:namespace, 5, :with_aggregation_schedule) } diff --git a/spec/workers/namespaces/root_statistics_worker_spec.rb b/spec/workers/namespaces/root_statistics_worker_spec.rb index 910a5b23e17..0c6e3e89973 100644 --- a/spec/workers/namespaces/root_statistics_worker_spec.rb +++ b/spec/workers/namespaces/root_statistics_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Namespaces::RootStatisticsWorker, '#perform' do +RSpec.describe Namespaces::RootStatisticsWorker, '#perform' do let(:group) { create(:group, :with_aggregation_schedule) } subject(:worker) { described_class.new } diff --git a/spec/workers/namespaces/schedule_aggregation_worker_spec.rb b/spec/workers/namespaces/schedule_aggregation_worker_spec.rb index 2f4c7f8bc07..f2fe53d6112 100644 --- a/spec/workers/namespaces/schedule_aggregation_worker_spec.rb +++ b/spec/workers/namespaces/schedule_aggregation_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Namespaces::ScheduleAggregationWorker, '#perform', :clean_gitlab_redis_shared_state do +RSpec.describe Namespaces::ScheduleAggregationWorker, '#perform', :clean_gitlab_redis_shared_state do let(:group) { create(:group) } subject(:worker) { described_class.new } diff --git a/spec/workers/new_issue_worker_spec.rb b/spec/workers/new_issue_worker_spec.rb index 1584e9d5302..6386af8d253 100644 --- a/spec/workers/new_issue_worker_spec.rb +++ b/spec/workers/new_issue_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe NewIssueWorker do +RSpec.describe NewIssueWorker do describe '#perform' do let(:worker) { described_class.new } diff --git a/spec/workers/new_merge_request_worker_spec.rb b/spec/workers/new_merge_request_worker_spec.rb index fe22226903f..37449540db5 100644 --- a/spec/workers/new_merge_request_worker_spec.rb +++ b/spec/workers/new_merge_request_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe NewMergeRequestWorker do +RSpec.describe NewMergeRequestWorker do describe '#perform' do let(:worker) { described_class.new } diff --git a/spec/workers/new_note_worker_spec.rb b/spec/workers/new_note_worker_spec.rb index 57269355180..21f10fa5bfb 100644 --- a/spec/workers/new_note_worker_spec.rb +++ b/spec/workers/new_note_worker_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe NewNoteWorker do +RSpec.describe NewNoteWorker do context 'when Note found' do let(:note) { create(:note) } diff --git a/spec/workers/new_release_worker_spec.rb b/spec/workers/new_release_worker_spec.rb deleted file mode 100644 index de4e1bac48f..00000000000 --- a/spec/workers/new_release_worker_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# TODO: Worker can be removed in 13.2: -# https://gitlab.com/gitlab-org/gitlab/-/issues/218231 -require 'spec_helper' - -describe NewReleaseWorker do - let(:release) { create(:release) } - - it 'sends a new release notification' do - expect_next_instance_of(NotificationService) do |instance| - expect(instance).to receive(:send_new_release_notifications).with(release) - end - - described_class.new.perform(release.id) - end -end diff --git a/spec/workers/object_pool/create_worker_spec.rb b/spec/workers/object_pool/create_worker_spec.rb index 06416489472..4ec409bdf47 100644 --- a/spec/workers/object_pool/create_worker_spec.rb +++ b/spec/workers/object_pool/create_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ObjectPool::CreateWorker do +RSpec.describe ObjectPool::CreateWorker do let(:pool) { create(:pool_repository, :scheduled) } subject { described_class.new } diff --git a/spec/workers/object_pool/destroy_worker_spec.rb b/spec/workers/object_pool/destroy_worker_spec.rb index 52d457b4b71..130a666a42e 100644 --- a/spec/workers/object_pool/destroy_worker_spec.rb +++ b/spec/workers/object_pool/destroy_worker_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe ObjectPool::DestroyWorker do +RSpec.describe ObjectPool::DestroyWorker do describe '#perform' do context 'when no pool is in the database' do it "doesn't raise an error" do diff --git a/spec/workers/object_pool/join_worker_spec.rb b/spec/workers/object_pool/join_worker_spec.rb index 906bc22c8d2..335c45e14e0 100644 --- a/spec/workers/object_pool/join_worker_spec.rb +++ b/spec/workers/object_pool/join_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ObjectPool::JoinWorker do +RSpec.describe ObjectPool::JoinWorker do let(:pool) { create(:pool_repository, :ready) } let(:project) { pool.source_project } let(:repository) { project.repository } diff --git a/spec/workers/packages/nuget/extraction_worker_spec.rb b/spec/workers/packages/nuget/extraction_worker_spec.rb new file mode 100644 index 00000000000..35b5f1baed5 --- /dev/null +++ b/spec/workers/packages/nuget/extraction_worker_spec.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Packages::Nuget::ExtractionWorker, type: :worker do + describe '#perform' do + let!(:package) { create(:nuget_package) } + let(:package_file) { package.package_files.first } + let(:package_file_id) { package_file.id } + + let_it_be(:package_name) { 'DummyProject.DummyPackage' } + let_it_be(:package_version) { '1.0.0' } + + subject { described_class.new.perform(package_file_id) } + + context 'with valid package file' do + it 'updates package and package file' do + expect { subject } + .to not_change { Packages::Package.count } + .and not_change { Packages::PackageFile.count } + end + + context 'with exisiting package' do + let!(:existing_package) { create(:nuget_package, project: package.project, name: package_name, version: package_version) } + + it 'reuses existing package and updates package file' do + expect { subject } + .to change { Packages::Package.count }.by(-1) + .and change { existing_package.reload.package_files.count }.by(1) + .and not_change { Packages::PackageFile.count } + end + end + end + + context 'with invalid package file id' do + let(:package_file_id) { 5555 } + + it "doesn't update package and package file" do + expect { subject } + .to not_change { package.reload.name } + .and not_change { package.version } + .and not_change { package_file.reload.file_name } + end + end + + context 'with package file not containing a nuspec file' do + before do + allow_any_instance_of(Zip::File).to receive(:glob).and_return([]) + end + + it 'removes the package and the package file' do + expect(Gitlab::ErrorTracking).to receive(:log_exception).with( + instance_of(::Packages::Nuget::MetadataExtractionService::ExtractionError), + project_id: package.project_id + ) + expect { subject } + .to change { Packages::Package.count }.by(-1) + .and change { Packages::PackageFile.count }.by(-1) + end + end + + context 'with package file with a blank package name' do + before do + allow_any_instance_of(::Packages::Nuget::UpdatePackageFromMetadataService).to receive(:package_name).and_return('') + end + + it 'removes the package and the package file' do + expect(Gitlab::ErrorTracking).to receive(:log_exception).with( + instance_of(::Packages::Nuget::UpdatePackageFromMetadataService::InvalidMetadataError), + project_id: package.project_id + ) + expect { subject } + .to change { Packages::Package.count }.by(-1) + .and change { Packages::PackageFile.count }.by(-1) + end + end + + context 'with package file with a blank package version' do + before do + allow_any_instance_of(::Packages::Nuget::UpdatePackageFromMetadataService).to receive(:package_version).and_return('') + end + + it 'removes the package and the package file' do + expect(Gitlab::ErrorTracking).to receive(:log_exception).with( + instance_of(::Packages::Nuget::UpdatePackageFromMetadataService::InvalidMetadataError), + project_id: package.project_id + ) + expect { subject } + .to change { Packages::Package.count }.by(-1) + .and change { Packages::PackageFile.count }.by(-1) + end + end + end +end diff --git a/spec/workers/pages_domain_removal_cron_worker_spec.rb b/spec/workers/pages_domain_removal_cron_worker_spec.rb index 2408ad54189..f152d019de6 100644 --- a/spec/workers/pages_domain_removal_cron_worker_spec.rb +++ b/spec/workers/pages_domain_removal_cron_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PagesDomainRemovalCronWorker do +RSpec.describe PagesDomainRemovalCronWorker do subject(:worker) { described_class.new } describe '#perform' do diff --git a/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb b/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb index 1349a80029b..7c745e51df5 100644 --- a/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb +++ b/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PagesDomainSslRenewalCronWorker do +RSpec.describe PagesDomainSslRenewalCronWorker do include LetsEncryptHelpers subject(:worker) { described_class.new } diff --git a/spec/workers/pages_domain_ssl_renewal_worker_spec.rb b/spec/workers/pages_domain_ssl_renewal_worker_spec.rb index a35965f49b2..f8149b23a08 100644 --- a/spec/workers/pages_domain_ssl_renewal_worker_spec.rb +++ b/spec/workers/pages_domain_ssl_renewal_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PagesDomainSslRenewalWorker do +RSpec.describe PagesDomainSslRenewalWorker do include LetsEncryptHelpers subject(:worker) { described_class.new } diff --git a/spec/workers/pages_domain_verification_cron_worker_spec.rb b/spec/workers/pages_domain_verification_cron_worker_spec.rb index 6dd6c33f5fe..01eaf984c90 100644 --- a/spec/workers/pages_domain_verification_cron_worker_spec.rb +++ b/spec/workers/pages_domain_verification_cron_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PagesDomainVerificationCronWorker do +RSpec.describe PagesDomainVerificationCronWorker do subject(:worker) { described_class.new } describe '#perform', :sidekiq do diff --git a/spec/workers/pages_domain_verification_worker_spec.rb b/spec/workers/pages_domain_verification_worker_spec.rb index f51ac1f4323..74b9730f7c1 100644 --- a/spec/workers/pages_domain_verification_worker_spec.rb +++ b/spec/workers/pages_domain_verification_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PagesDomainVerificationWorker do +RSpec.describe PagesDomainVerificationWorker do subject(:worker) { described_class.new } let(:domain) { create(:pages_domain) } diff --git a/spec/workers/partition_creation_worker_spec.rb b/spec/workers/partition_creation_worker_spec.rb new file mode 100644 index 00000000000..50ed9c901c1 --- /dev/null +++ b/spec/workers/partition_creation_worker_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe PartitionCreationWorker do + describe '#perform' do + let(:creator) { double(create_partitions: nil) } + + before do + allow(Gitlab::Database::Partitioning::PartitionCreator).to receive(:new).and_return(creator) + end + + it 'delegates to PartitionCreator' do + expect(creator).to receive(:create_partitions) + + described_class.new.perform + end + end +end diff --git a/spec/workers/pipeline_hooks_worker_spec.rb b/spec/workers/pipeline_hooks_worker_spec.rb index 60df08f40da..7c75cdc8823 100644 --- a/spec/workers/pipeline_hooks_worker_spec.rb +++ b/spec/workers/pipeline_hooks_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PipelineHooksWorker do +RSpec.describe PipelineHooksWorker do describe '#perform' do context 'when pipeline exists' do let(:pipeline) { create(:ci_pipeline) } diff --git a/spec/workers/pipeline_metrics_worker_spec.rb b/spec/workers/pipeline_metrics_worker_spec.rb index 6beecbcd114..c73b84e26a6 100644 --- a/spec/workers/pipeline_metrics_worker_spec.rb +++ b/spec/workers/pipeline_metrics_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PipelineMetricsWorker do +RSpec.describe PipelineMetricsWorker do let(:project) { create(:project, :repository) } let!(:merge_request) do @@ -18,7 +18,7 @@ describe PipelineMetricsWorker do ref: 'master', sha: project.repository.commit('master').id, started_at: 1.hour.ago, - finished_at: Time.now) + finished_at: Time.current) end let(:status) { 'pending' } diff --git a/spec/workers/pipeline_notification_worker_spec.rb b/spec/workers/pipeline_notification_worker_spec.rb index f2cc2b56236..9a15864173c 100644 --- a/spec/workers/pipeline_notification_worker_spec.rb +++ b/spec/workers/pipeline_notification_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PipelineNotificationWorker, :mailer do +RSpec.describe PipelineNotificationWorker, :mailer do let_it_be(:pipeline) { create(:ci_pipeline) } describe '#execute' do diff --git a/spec/workers/pipeline_process_worker_spec.rb b/spec/workers/pipeline_process_worker_spec.rb index 8260d7ac320..a6e6b505a38 100644 --- a/spec/workers/pipeline_process_worker_spec.rb +++ b/spec/workers/pipeline_process_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PipelineProcessWorker do +RSpec.describe PipelineProcessWorker do describe '#perform' do context 'when pipeline exists' do let(:pipeline) { create(:ci_pipeline) } diff --git a/spec/workers/pipeline_schedule_worker_spec.rb b/spec/workers/pipeline_schedule_worker_spec.rb index 758cfa82d5d..f59d8ad4615 100644 --- a/spec/workers/pipeline_schedule_worker_spec.rb +++ b/spec/workers/pipeline_schedule_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PipelineScheduleWorker do +RSpec.describe PipelineScheduleWorker do include ExclusiveLeaseHelpers subject { described_class.new.perform } @@ -33,7 +33,7 @@ describe PipelineScheduleWorker do expect(Ci::Pipeline.last).to be_schedule pipeline_schedule.reload - expect(pipeline_schedule.next_run_at).to be > Time.now + expect(pipeline_schedule.next_run_at).to be > Time.current expect(pipeline_schedule).to eq(project.ci_pipelines.last.pipeline_schedule) expect(pipeline_schedule).to be_active end diff --git a/spec/workers/pipeline_update_ci_ref_status_worker_service_spec.rb b/spec/workers/pipeline_update_ci_ref_status_worker_service_spec.rb index 3fe8aa55142..4e7af16c63d 100644 --- a/spec/workers/pipeline_update_ci_ref_status_worker_service_spec.rb +++ b/spec/workers/pipeline_update_ci_ref_status_worker_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # NOTE: This class is unused and to be removed in 13.1~ -describe PipelineUpdateCiRefStatusWorker do +RSpec.describe PipelineUpdateCiRefStatusWorker do let(:worker) { described_class.new } let(:pipeline) { create(:ci_pipeline) } diff --git a/spec/workers/pipeline_update_worker_spec.rb b/spec/workers/pipeline_update_worker_spec.rb index 187298034cc..c5c1cc0eefd 100644 --- a/spec/workers/pipeline_update_worker_spec.rb +++ b/spec/workers/pipeline_update_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PipelineUpdateWorker do +RSpec.describe PipelineUpdateWorker do describe '#perform' do context 'when pipeline exists' do let(:pipeline) { create(:ci_pipeline) } @@ -12,6 +12,14 @@ describe PipelineUpdateWorker do described_class.new.perform(pipeline.id) end + + include_examples 'an idempotent worker' do + let(:job_args) { [pipeline.id] } + + it 'sets pipeline status to skipped' do + expect { subject }.to change { pipeline.reload.status }.from('pending').to('skipped') + end + end end context 'when pipeline does not exist' do diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 18e06332eb3..f64ee4aa2f7 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PostReceive do +RSpec.describe PostReceive do let(:changes) { "123456 789012 refs/heads/tést\n654321 210987 refs/tags/tag" } let(:wrongly_encoded_changes) { changes.encode("ISO-8859-1").force_encoding("UTF-8") } let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) } @@ -428,7 +428,12 @@ describe PostReceive do it 'expires the status cache' do expect(snippet.repository).to receive(:empty?).and_return(true) expect(snippet.repository).to receive(:expire_status_cache) - expect(snippet.repository).to receive(:expire_statistics_caches) + + perform + end + + it 'updates snippet statistics' do + expect(Snippets::UpdateStatisticsService).to receive(:new).with(snippet).and_call_original perform end diff --git a/spec/workers/process_commit_worker_spec.rb b/spec/workers/process_commit_worker_spec.rb index d247668ac76..a33ee6e1da5 100644 --- a/spec/workers/process_commit_worker_spec.rb +++ b/spec/workers/process_commit_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ProcessCommitWorker do +RSpec.describe ProcessCommitWorker do let(:worker) { described_class.new } let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } @@ -200,9 +200,9 @@ describe ProcessCommitWorker do it 'parses date strings into Time instances' do commit = worker.build_commit(project, id: '123', - authored_date: Time.now.to_s) + authored_date: Time.current.to_s) - expect(commit.authored_date).to be_an_instance_of(Time) + expect(commit.authored_date).to be_a_kind_of(Time) end end end diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index fa02762d716..0f91f7af255 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ProjectCacheWorker do +RSpec.describe ProjectCacheWorker do include ExclusiveLeaseHelpers let(:worker) { described_class.new } diff --git a/spec/workers/project_daily_statistics_worker_spec.rb b/spec/workers/project_daily_statistics_worker_spec.rb index 8640add99e5..fa9d938acca 100644 --- a/spec/workers/project_daily_statistics_worker_spec.rb +++ b/spec/workers/project_daily_statistics_worker_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe ProjectDailyStatisticsWorker, '#perform' do +RSpec.describe ProjectDailyStatisticsWorker, '#perform' do let(:worker) { described_class.new } let(:project) { create(:project) } diff --git a/spec/workers/project_destroy_worker_spec.rb b/spec/workers/project_destroy_worker_spec.rb index ec40900a5b7..00a4ddac29f 100644 --- a/spec/workers/project_destroy_worker_spec.rb +++ b/spec/workers/project_destroy_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ProjectDestroyWorker do +RSpec.describe ProjectDestroyWorker do let(:project) { create(:project, :repository, pending_delete: true) } let(:path) do Gitlab::GitalyClient::StorageSettings.allow_disk_access do diff --git a/spec/workers/project_export_worker_spec.rb b/spec/workers/project_export_worker_spec.rb index 4c49939d34e..1f54b6766a4 100644 --- a/spec/workers/project_export_worker_spec.rb +++ b/spec/workers/project_export_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ProjectExportWorker do +RSpec.describe ProjectExportWorker do let!(:user) { create(:user) } let!(:project) { create(:project) } @@ -69,4 +69,14 @@ describe ProjectExportWorker do end end end + + describe 'sidekiq options' do + it 'disables retry' do + expect(described_class.sidekiq_options['retry']).to eq(false) + end + + it 'sets default status expiration' do + expect(described_class.sidekiq_options['status_expiration']).to eq(StuckExportJobsWorker::EXPORT_JOBS_EXPIRATION) + end + end end diff --git a/spec/workers/project_service_worker_spec.rb b/spec/workers/project_service_worker_spec.rb index 56934f122e4..c638b7472ff 100644 --- a/spec/workers/project_service_worker_spec.rb +++ b/spec/workers/project_service_worker_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -describe ProjectServiceWorker, '#perform' do +RSpec.describe ProjectServiceWorker, '#perform' do let(:worker) { described_class.new } let(:service) { JiraService.new } diff --git a/spec/workers/project_update_repository_storage_worker_spec.rb b/spec/workers/project_update_repository_storage_worker_spec.rb index 98856480b21..f75bb3d1642 100644 --- a/spec/workers/project_update_repository_storage_worker_spec.rb +++ b/spec/workers/project_update_repository_storage_worker_spec.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true require 'spec_helper' -require 'securerandom' -describe ProjectUpdateRepositoryStorageWorker do +RSpec.describe ProjectUpdateRepositoryStorageWorker do let(:project) { create(:project, :repository) } subject { described_class.new } diff --git a/spec/workers/prometheus/create_default_alerts_worker_spec.rb b/spec/workers/prometheus/create_default_alerts_worker_spec.rb index 1b1867d5bb6..105fa0415d9 100644 --- a/spec/workers/prometheus/create_default_alerts_worker_spec.rb +++ b/spec/workers/prometheus/create_default_alerts_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Prometheus::CreateDefaultAlertsWorker do +RSpec.describe Prometheus::CreateDefaultAlertsWorker do let_it_be(:project) { create(:project) } let(:worker) { described_class.new } let(:logger) { worker.send(:logger) } diff --git a/spec/workers/propagate_integration_worker_spec.rb b/spec/workers/propagate_integration_worker_spec.rb index e49869a38e9..a0fdd37b3c0 100644 --- a/spec/workers/propagate_integration_worker_spec.rb +++ b/spec/workers/propagate_integration_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PropagateIntegrationWorker do +RSpec.describe PropagateIntegrationWorker do describe '#perform' do let(:integration) do PushoverService.create( diff --git a/spec/workers/propagate_service_template_worker_spec.rb b/spec/workers/propagate_service_template_worker_spec.rb index fb4ced77832..4cba313a23f 100644 --- a/spec/workers/propagate_service_template_worker_spec.rb +++ b/spec/workers/propagate_service_template_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PropagateServiceTemplateWorker do +RSpec.describe PropagateServiceTemplateWorker do include ExclusiveLeaseHelpers describe '#perform' do diff --git a/spec/workers/prune_old_events_worker_spec.rb b/spec/workers/prune_old_events_worker_spec.rb index 14235bde070..c1ba9128475 100644 --- a/spec/workers/prune_old_events_worker_spec.rb +++ b/spec/workers/prune_old_events_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PruneOldEventsWorker do +RSpec.describe PruneOldEventsWorker do describe '#perform' do let(:user) { create(:user) } diff --git a/spec/workers/prune_web_hook_logs_worker_spec.rb b/spec/workers/prune_web_hook_logs_worker_spec.rb index e57334967fd..6cd7a54ac7a 100644 --- a/spec/workers/prune_web_hook_logs_worker_spec.rb +++ b/spec/workers/prune_web_hook_logs_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PruneWebHookLogsWorker do +RSpec.describe PruneWebHookLogsWorker do describe '#perform' do before do hook = create(:project_hook) diff --git a/spec/workers/reactive_caching_worker_spec.rb b/spec/workers/reactive_caching_worker_spec.rb index dcb804a7e6e..63b26817a7a 100644 --- a/spec/workers/reactive_caching_worker_spec.rb +++ b/spec/workers/reactive_caching_worker_spec.rb @@ -2,6 +2,6 @@ require 'spec_helper' -describe ReactiveCachingWorker do +RSpec.describe ReactiveCachingWorker do it_behaves_like 'reactive cacheable worker' end diff --git a/spec/workers/rebase_worker_spec.rb b/spec/workers/rebase_worker_spec.rb index 578b8cf7451..9246b283be5 100644 --- a/spec/workers/rebase_worker_spec.rb +++ b/spec/workers/rebase_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RebaseWorker, '#perform' do +RSpec.describe RebaseWorker, '#perform' do include ProjectForksHelper context 'when rebasing an MR from a fork where upstream has protected branches' do diff --git a/spec/workers/remote_mirror_notification_worker_spec.rb b/spec/workers/remote_mirror_notification_worker_spec.rb index f0fb46f84d9..c6fd614fdea 100644 --- a/spec/workers/remote_mirror_notification_worker_spec.rb +++ b/spec/workers/remote_mirror_notification_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RemoteMirrorNotificationWorker, :mailer do +RSpec.describe RemoteMirrorNotificationWorker, :mailer do let_it_be(:project) { create(:project, :repository, :remote_mirror) } let_it_be(:mirror) { project.remote_mirrors.first } diff --git a/spec/workers/remove_expired_group_links_worker_spec.rb b/spec/workers/remove_expired_group_links_worker_spec.rb index b637802cd78..91031768632 100644 --- a/spec/workers/remove_expired_group_links_worker_spec.rb +++ b/spec/workers/remove_expired_group_links_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RemoveExpiredGroupLinksWorker do +RSpec.describe RemoveExpiredGroupLinksWorker do describe '#perform' do context 'ProjectGroupLinks' do let!(:expired_project_group_link) { create(:project_group_link, expires_at: 1.hour.ago) } diff --git a/spec/workers/remove_expired_members_worker_spec.rb b/spec/workers/remove_expired_members_worker_spec.rb index 69a5725bb35..cbdd5a68698 100644 --- a/spec/workers/remove_expired_members_worker_spec.rb +++ b/spec/workers/remove_expired_members_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RemoveExpiredMembersWorker do +RSpec.describe RemoveExpiredMembersWorker do let(:worker) { described_class.new } describe '#perform' do diff --git a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb index 0e21933a9a5..e716d4806d3 100644 --- a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb +++ b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RemoveUnreferencedLfsObjectsWorker do +RSpec.describe RemoveUnreferencedLfsObjectsWorker do let(:worker) { described_class.new } describe '#perform' do diff --git a/spec/workers/repository_check/batch_worker_spec.rb b/spec/workers/repository_check/batch_worker_spec.rb index 12e7d1879d0..643b55af573 100644 --- a/spec/workers/repository_check/batch_worker_spec.rb +++ b/spec/workers/repository_check/batch_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RepositoryCheck::BatchWorker do +RSpec.describe RepositoryCheck::BatchWorker do let(:shard_name) { 'default' } subject { described_class.new } diff --git a/spec/workers/repository_check/clear_worker_spec.rb b/spec/workers/repository_check/clear_worker_spec.rb index 7ad9e287204..b5f09e8a05f 100644 --- a/spec/workers/repository_check/clear_worker_spec.rb +++ b/spec/workers/repository_check/clear_worker_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' -describe RepositoryCheck::ClearWorker do +RSpec.describe RepositoryCheck::ClearWorker do it 'clears repository check columns' do project = create(:project) project.update_columns( last_repository_check_failed: true, - last_repository_check_at: Time.now + last_repository_check_at: Time.current ) described_class.new.perform diff --git a/spec/workers/repository_check/dispatch_worker_spec.rb b/spec/workers/repository_check/dispatch_worker_spec.rb index e4bb0bf4046..5e1bc76ec8e 100644 --- a/spec/workers/repository_check/dispatch_worker_spec.rb +++ b/spec/workers/repository_check/dispatch_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RepositoryCheck::DispatchWorker do +RSpec.describe RepositoryCheck::DispatchWorker do subject { described_class.new } it 'does nothing when repository checks are disabled' do diff --git a/spec/workers/repository_check/single_repository_worker_spec.rb b/spec/workers/repository_check/single_repository_worker_spec.rb index 43998f912ef..28e3f43d374 100644 --- a/spec/workers/repository_check/single_repository_worker_spec.rb +++ b/spec/workers/repository_check/single_repository_worker_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'fileutils' -describe RepositoryCheck::SingleRepositoryWorker do +RSpec.describe RepositoryCheck::SingleRepositoryWorker do subject(:worker) { described_class.new } it 'skips when the project has no push events' do diff --git a/spec/workers/repository_cleanup_worker_spec.rb b/spec/workers/repository_cleanup_worker_spec.rb index e58664cf22a..41bfeabb7f3 100644 --- a/spec/workers/repository_cleanup_worker_spec.rb +++ b/spec/workers/repository_cleanup_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RepositoryCleanupWorker do +RSpec.describe RepositoryCleanupWorker do let(:project) { create(:project) } let(:user) { create(:user) } diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index 7209c40646f..0f2d4eb4b65 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RepositoryForkWorker do +RSpec.describe RepositoryForkWorker do include ProjectForksHelper describe 'modules' do diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index 507098582c9..a2c19debdfd 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -2,13 +2,7 @@ require 'spec_helper' -describe RepositoryImportWorker do - describe 'modules' do - it 'includes ProjectImportOptions' do - expect(described_class).to include_module(ProjectImportOptions) - end - end - +RSpec.describe RepositoryImportWorker do describe '#perform' do let(:project) { create(:project, :import_scheduled) } let(:import_state) { project.import_state } diff --git a/spec/workers/repository_remove_remote_worker_spec.rb b/spec/workers/repository_remove_remote_worker_spec.rb index afac9212fab..7d66131f34e 100644 --- a/spec/workers/repository_remove_remote_worker_spec.rb +++ b/spec/workers/repository_remove_remote_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RepositoryRemoveRemoteWorker do +RSpec.describe RepositoryRemoveRemoteWorker do include ExclusiveLeaseHelpers include GitHelpers @@ -32,7 +32,7 @@ describe RepositoryRemoveRemoteWorker do expect(subject) .to receive(:log_error) - .with('Cannot obtain an exclusive lease. There must be another instance already in execution.') + .with("Cannot obtain an exclusive lease for #{subject.class.name}. There must be another instance already in execution.") subject.perform(project.id, remote_name) end diff --git a/spec/workers/repository_update_remote_mirror_worker_spec.rb b/spec/workers/repository_update_remote_mirror_worker_spec.rb index 7bc499d480d..37eed57cf2e 100644 --- a/spec/workers/repository_update_remote_mirror_worker_spec.rb +++ b/spec/workers/repository_update_remote_mirror_worker_spec.rb @@ -2,14 +2,14 @@ require 'spec_helper' -describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do +RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do subject { described_class.new } let(:remote_mirror) { create(:remote_mirror) } - let(:scheduled_time) { Time.now - 5.minutes } + let(:scheduled_time) { Time.current - 5.minutes } around do |example| - Timecop.freeze(Time.now) { example.run } + Timecop.freeze(Time.current) { example.run } end def expect_mirror_service_to_return(mirror, result, tries = 0) @@ -26,7 +26,7 @@ describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do end it 'does not do anything if the mirror was already updated' do - remote_mirror.update(last_update_started_at: Time.now, update_status: :finished) + remote_mirror.update(last_update_started_at: Time.current, update_status: :finished) expect(Projects::UpdateRemoteMirrorService).not_to receive(:new) @@ -48,7 +48,7 @@ describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do expect_next_instance_of(Projects::UpdateRemoteMirrorService) do |service| expect(service).to receive(:execute).with(remote_mirror, 1).and_raise('Unexpected!') end - expect { subject.perform(remote_mirror.id, Time.now, 1) }.to raise_error('Unexpected!') + expect { subject.perform(remote_mirror.id, Time.current, 1) }.to raise_error('Unexpected!') lease = Gitlab::ExclusiveLease.new("#{described_class.name}:#{remote_mirror.id}", timeout: 1.second) diff --git a/spec/workers/run_pipeline_schedule_worker_spec.rb b/spec/workers/run_pipeline_schedule_worker_spec.rb index afeee4bac73..4999909934b 100644 --- a/spec/workers/run_pipeline_schedule_worker_spec.rb +++ b/spec/workers/run_pipeline_schedule_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe RunPipelineScheduleWorker do +RSpec.describe RunPipelineScheduleWorker do describe '#perform' do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } diff --git a/spec/workers/schedule_migrate_external_diffs_worker_spec.rb b/spec/workers/schedule_migrate_external_diffs_worker_spec.rb index 9d6fecc9f4e..09a0124f6e0 100644 --- a/spec/workers/schedule_migrate_external_diffs_worker_spec.rb +++ b/spec/workers/schedule_migrate_external_diffs_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ScheduleMigrateExternalDiffsWorker do +RSpec.describe ScheduleMigrateExternalDiffsWorker do include ExclusiveLeaseHelpers let(:worker) { described_class.new } diff --git a/spec/workers/self_monitoring_project_create_worker_spec.rb b/spec/workers/self_monitoring_project_create_worker_spec.rb index 00c288bdc46..b618b8ede99 100644 --- a/spec/workers/self_monitoring_project_create_worker_spec.rb +++ b/spec/workers/self_monitoring_project_create_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe SelfMonitoringProjectCreateWorker do +RSpec.describe SelfMonitoringProjectCreateWorker do describe '#perform' do let(:service_class) { Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService } let(:service) { instance_double(service_class) } diff --git a/spec/workers/self_monitoring_project_delete_worker_spec.rb b/spec/workers/self_monitoring_project_delete_worker_spec.rb index 3685c73513e..9a53fe59a40 100644 --- a/spec/workers/self_monitoring_project_delete_worker_spec.rb +++ b/spec/workers/self_monitoring_project_delete_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe SelfMonitoringProjectDeleteWorker do +RSpec.describe SelfMonitoringProjectDeleteWorker do let_it_be(:jid) { 'b5b28910d97563e58c2fe55f' } let_it_be(:data_key) { "self_monitoring_delete_result:#{jid}" } diff --git a/spec/workers/service_desk_email_receiver_worker_spec.rb b/spec/workers/service_desk_email_receiver_worker_spec.rb new file mode 100644 index 00000000000..d3bfa51348e --- /dev/null +++ b/spec/workers/service_desk_email_receiver_worker_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe ServiceDeskEmailReceiverWorker, :mailer do + describe '#perform' do + let(:worker) { described_class.new } + let(:email) { fixture_file('emails/service_desk_custom_address.eml') } + + context 'when service_desk_email config is enabled' do + before do + stub_service_desk_email_setting(enabled: true, address: 'foo') + end + + it 'does not ignore the email' do + expect(Gitlab::Email::ServiceDeskReceiver).to receive(:new) + + worker.perform(email) + end + + context 'when service desk receiver raises an exception' do + before do + allow_next_instance_of(Gitlab::Email::ServiceDeskReceiver) do |receiver| + allow(receiver).to receive(:find_handler).and_return(nil) + end + end + + it 'sends a rejection email' do + perform_enqueued_jobs do + worker.perform(email) + end + + reply = ActionMailer::Base.deliveries.last + expect(reply).not_to be_nil + expect(reply.to).to eq(['jake@adventuretime.ooo']) + expect(reply.subject).to include('Rejected') + end + end + end + + context 'when service_desk_email config is disabled' do + before do + stub_service_desk_email_setting(enabled: false, address: 'foo') + end + + it 'ignores the email' do + expect(Gitlab::Email::ServiceDeskReceiver).not_to receive(:new) + + worker.perform(email) + end + end + end +end diff --git a/spec/workers/stage_update_worker_spec.rb b/spec/workers/stage_update_worker_spec.rb index dc7158cfd2f..75b324a9e0a 100644 --- a/spec/workers/stage_update_worker_spec.rb +++ b/spec/workers/stage_update_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe StageUpdateWorker do +RSpec.describe StageUpdateWorker do describe '#perform' do context 'when stage exists' do let(:stage) { create(:ci_stage_entity) } diff --git a/spec/workers/stuck_ci_jobs_worker_spec.rb b/spec/workers/stuck_ci_jobs_worker_spec.rb index c994a5dcb78..b96d506771d 100644 --- a/spec/workers/stuck_ci_jobs_worker_spec.rb +++ b/spec/workers/stuck_ci_jobs_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe StuckCiJobsWorker do +RSpec.describe StuckCiJobsWorker do include ExclusiveLeaseHelpers let!(:runner) { create :ci_runner } diff --git a/spec/workers/stuck_export_jobs_worker_spec.rb b/spec/workers/stuck_export_jobs_worker_spec.rb index fc5758fdadf..cbc7adc8e3f 100644 --- a/spec/workers/stuck_export_jobs_worker_spec.rb +++ b/spec/workers/stuck_export_jobs_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe StuckExportJobsWorker do +RSpec.describe StuckExportJobsWorker do let(:worker) { described_class.new } shared_examples 'project export job detection' do diff --git a/spec/workers/stuck_import_jobs_worker_spec.rb b/spec/workers/stuck_import_jobs_worker_spec.rb deleted file mode 100644 index f8d7f8747d5..00000000000 --- a/spec/workers/stuck_import_jobs_worker_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe StuckImportJobsWorker do - let(:worker) { described_class.new } - - describe 'with scheduled import_status' do - it_behaves_like 'stuck import job detection' do - let(:import_state) { create(:project, :import_scheduled).import_state } - - before do - import_state.update(jid: '123') - end - end - end - - describe 'with started import_status' do - it_behaves_like 'stuck import job detection' do - let(:import_state) { create(:project, :import_started).import_state } - - before do - import_state.update(jid: '123') - end - end - end -end diff --git a/spec/workers/stuck_merge_jobs_worker_spec.rb b/spec/workers/stuck_merge_jobs_worker_spec.rb index 8ceaf1fc555..bade2e1ca1b 100644 --- a/spec/workers/stuck_merge_jobs_worker_spec.rb +++ b/spec/workers/stuck_merge_jobs_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe StuckMergeJobsWorker do +RSpec.describe StuckMergeJobsWorker do describe 'perform' do let(:worker) { described_class.new } diff --git a/spec/workers/system_hook_push_worker_spec.rb b/spec/workers/system_hook_push_worker_spec.rb index 890a622d11a..43a3f8e3e19 100644 --- a/spec/workers/system_hook_push_worker_spec.rb +++ b/spec/workers/system_hook_push_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe SystemHookPushWorker do +RSpec.describe SystemHookPushWorker do include RepoHelpers subject { described_class.new } diff --git a/spec/workers/todos_destroyer/confidential_issue_worker_spec.rb b/spec/workers/todos_destroyer/confidential_issue_worker_spec.rb index 0907e2768ba..86202fac1ed 100644 --- a/spec/workers/todos_destroyer/confidential_issue_worker_spec.rb +++ b/spec/workers/todos_destroyer/confidential_issue_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe TodosDestroyer::ConfidentialIssueWorker do +RSpec.describe TodosDestroyer::ConfidentialIssueWorker do let(:service) { double } it "calls the Todos::Destroy::ConfidentialIssueService with issue_id parameter" do diff --git a/spec/workers/todos_destroyer/entity_leave_worker_spec.rb b/spec/workers/todos_destroyer/entity_leave_worker_spec.rb index cb14fac0910..db3b0252056 100644 --- a/spec/workers/todos_destroyer/entity_leave_worker_spec.rb +++ b/spec/workers/todos_destroyer/entity_leave_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe TodosDestroyer::EntityLeaveWorker do +RSpec.describe TodosDestroyer::EntityLeaveWorker do it "calls the Todos::Destroy::EntityLeaveService with the params it was given" do service = double diff --git a/spec/workers/todos_destroyer/group_private_worker_spec.rb b/spec/workers/todos_destroyer/group_private_worker_spec.rb index d9a240136d5..4903edd4bbe 100644 --- a/spec/workers/todos_destroyer/group_private_worker_spec.rb +++ b/spec/workers/todos_destroyer/group_private_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe TodosDestroyer::GroupPrivateWorker do +RSpec.describe TodosDestroyer::GroupPrivateWorker do it "calls the Todos::Destroy::GroupPrivateService with the params it was given" do service = double diff --git a/spec/workers/todos_destroyer/private_features_worker_spec.rb b/spec/workers/todos_destroyer/private_features_worker_spec.rb index abd04acc3bd..f346a004670 100644 --- a/spec/workers/todos_destroyer/private_features_worker_spec.rb +++ b/spec/workers/todos_destroyer/private_features_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe TodosDestroyer::PrivateFeaturesWorker do +RSpec.describe TodosDestroyer::PrivateFeaturesWorker do it "calls the Todos::Destroy::PrivateFeaturesService with the params it was given" do service = double diff --git a/spec/workers/todos_destroyer/project_private_worker_spec.rb b/spec/workers/todos_destroyer/project_private_worker_spec.rb index c1bb0438ec3..4e54fbdb275 100644 --- a/spec/workers/todos_destroyer/project_private_worker_spec.rb +++ b/spec/workers/todos_destroyer/project_private_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe TodosDestroyer::ProjectPrivateWorker do +RSpec.describe TodosDestroyer::ProjectPrivateWorker do it "calls the Todos::Destroy::ProjectPrivateService with the params it was given" do service = double diff --git a/spec/workers/trending_projects_worker_spec.rb b/spec/workers/trending_projects_worker_spec.rb index 6e524085662..1f1e312e457 100644 --- a/spec/workers/trending_projects_worker_spec.rb +++ b/spec/workers/trending_projects_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe TrendingProjectsWorker do +RSpec.describe TrendingProjectsWorker do describe '#perform' do it 'refreshes the trending projects' do expect(TrendingProject).to receive(:refresh!) diff --git a/spec/workers/update_container_registry_info_worker_spec.rb b/spec/workers/update_container_registry_info_worker_spec.rb new file mode 100644 index 00000000000..ace9e55cbce --- /dev/null +++ b/spec/workers/update_container_registry_info_worker_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe UpdateContainerRegistryInfoWorker do + describe '#perform' do + it 'calls UpdateContainerRegistryInfoService' do + expect_next_instance_of(UpdateContainerRegistryInfoService) do |service| + expect(service).to receive(:execute) + end + + subject.perform + end + end +end diff --git a/spec/workers/update_external_pull_requests_worker_spec.rb b/spec/workers/update_external_pull_requests_worker_spec.rb index afac0357b2d..80f22470977 100644 --- a/spec/workers/update_external_pull_requests_worker_spec.rb +++ b/spec/workers/update_external_pull_requests_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe UpdateExternalPullRequestsWorker do +RSpec.describe UpdateExternalPullRequestsWorker do describe '#perform' do let_it_be(:project) { create(:project, import_source: 'tanuki/repository') } let_it_be(:user) { create(:user) } diff --git a/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb b/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb index 8fe3f27c8b1..e6f4f415987 100644 --- a/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb +++ b/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe UpdateHeadPipelineForMergeRequestWorker do +RSpec.describe UpdateHeadPipelineForMergeRequestWorker do describe '#perform' do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository) } diff --git a/spec/workers/update_highest_role_worker_spec.rb b/spec/workers/update_highest_role_worker_spec.rb index 3f377208a62..19512fb0cfc 100644 --- a/spec/workers/update_highest_role_worker_spec.rb +++ b/spec/workers/update_highest_role_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe UpdateHighestRoleWorker, :clean_gitlab_redis_shared_state do +RSpec.describe UpdateHighestRoleWorker, :clean_gitlab_redis_shared_state do include ExclusiveLeaseHelpers let(:worker) { described_class.new } diff --git a/spec/workers/update_merge_requests_worker_spec.rb b/spec/workers/update_merge_requests_worker_spec.rb index 14a363f9d59..fb12086c2f4 100644 --- a/spec/workers/update_merge_requests_worker_spec.rb +++ b/spec/workers/update_merge_requests_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe UpdateMergeRequestsWorker do +RSpec.describe UpdateMergeRequestsWorker do include RepoHelpers let(:project) { create(:project, :repository) } diff --git a/spec/workers/update_project_statistics_worker_spec.rb b/spec/workers/update_project_statistics_worker_spec.rb index 191075f1a52..1f840e363ea 100644 --- a/spec/workers/update_project_statistics_worker_spec.rb +++ b/spec/workers/update_project_statistics_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe UpdateProjectStatisticsWorker do +RSpec.describe UpdateProjectStatisticsWorker do let(:worker) { described_class.new } let(:project) { create(:project, :repository) } let(:statistics) { %w(repository_size) } diff --git a/spec/workers/upload_checksum_worker_spec.rb b/spec/workers/upload_checksum_worker_spec.rb index 44e9e4f048d..75d7509b6e6 100644 --- a/spec/workers/upload_checksum_worker_spec.rb +++ b/spec/workers/upload_checksum_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe UploadChecksumWorker do +RSpec.describe UploadChecksumWorker do describe '#perform' do subject { described_class.new } diff --git a/spec/workers/users/create_statistics_worker_spec.rb b/spec/workers/users/create_statistics_worker_spec.rb index 3b2b72a832d..e3f082313a0 100644 --- a/spec/workers/users/create_statistics_worker_spec.rb +++ b/spec/workers/users/create_statistics_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Users::CreateStatisticsWorker do +RSpec.describe Users::CreateStatisticsWorker do describe '#perform' do subject { described_class.new.perform } diff --git a/spec/workers/wait_for_cluster_creation_worker_spec.rb b/spec/workers/wait_for_cluster_creation_worker_spec.rb index b21a9b612af..9079dff1afe 100644 --- a/spec/workers/wait_for_cluster_creation_worker_spec.rb +++ b/spec/workers/wait_for_cluster_creation_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe WaitForClusterCreationWorker do +RSpec.describe WaitForClusterCreationWorker do describe '#perform' do context 'when provider type is gcp' do let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) } diff --git a/spec/workers/x509_certificate_revoke_worker_spec.rb b/spec/workers/x509_certificate_revoke_worker_spec.rb index 1e0cbf61267..392cb52d084 100644 --- a/spec/workers/x509_certificate_revoke_worker_spec.rb +++ b/spec/workers/x509_certificate_revoke_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe X509CertificateRevokeWorker do +RSpec.describe X509CertificateRevokeWorker do describe '#perform' do context 'with a revoked certificate' do subject { described_class.new } diff --git a/spec/workers/x509_issuer_crl_check_worker_spec.rb b/spec/workers/x509_issuer_crl_check_worker_spec.rb index f052812b86b..5564147d274 100644 --- a/spec/workers/x509_issuer_crl_check_worker_spec.rb +++ b/spec/workers/x509_issuer_crl_check_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe X509IssuerCrlCheckWorker do +RSpec.describe X509IssuerCrlCheckWorker do subject(:worker) { described_class.new } let(:project) { create(:project, :public, :repository) } |