diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 09:40:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 09:40:42 +0000 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) | |
download | gitlab-ce-ee664acb356f8123f4f6b00b73c1e1cf0866c7fb.tar.gz |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb')
-rw-r--r-- | spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb b/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb index cb2cf58d50b..3b33972c76f 100644 --- a/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb +++ b/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb @@ -27,15 +27,18 @@ RSpec.describe Ci::PipelineSuccessUnlockArtifactsWorker do end context 'when pipeline exists' do - let(:pipeline) { create(:ci_pipeline, :success, :with_job) } + 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 + before do + allow(Ci::Pipeline).to receive(:find_by_id).with(pipeline.id).and_return(pipeline) + allow(pipeline).to receive(:has_erasable_artifacts?).and_return(has_erasable_artifacts) + end - it 'calls the service' do + context 'when pipeline has erasable artifacts' do + let(:has_erasable_artifacts) { true } + + it 'calls the unlock service' do service = spy(Ci::UnlockArtifactsService) expect(Ci::UnlockArtifactsService).to receive(:new).and_return(service) @@ -45,8 +48,10 @@ RSpec.describe Ci::PipelineSuccessUnlockArtifactsWorker do end end - context 'when pipeline does not have artifacts' do - it 'does not call service' do + context 'when pipeline has no erasable artifacts' do + let(:has_erasable_artifacts) { false } + + it 'does not call the unlock service' do expect(Ci::UnlockArtifactsService).not_to receive(:new) perform |