summaryrefslogtreecommitdiff
path: root/spec/workers/ci
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-24 12:10:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-24 12:10:17 +0000
commit4b9bde7848d9538c1635ffe7a5385ba013487b4a (patch)
tree5aad1d5d94ea233a36c8ac2850e099236e1c2cdc /spec/workers/ci
parent2f752481c2e727834216a93dee82df9f8e2acb2e (diff)
downloadgitlab-ce-4b9bde7848d9538c1635ffe7a5385ba013487b4a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/ci')
-rw-r--r--spec/workers/ci/ref_delete_unlock_artifacts_worker_spec.rb26
1 files changed, 20 insertions, 6 deletions
diff --git a/spec/workers/ci/ref_delete_unlock_artifacts_worker_spec.rb b/spec/workers/ci/ref_delete_unlock_artifacts_worker_spec.rb
index d9f2dd326dd..f510852e753 100644
--- a/spec/workers/ci/ref_delete_unlock_artifacts_worker_spec.rb
+++ b/spec/workers/ci/ref_delete_unlock_artifacts_worker_spec.rb
@@ -29,10 +29,8 @@ RSpec.describe Ci::RefDeleteUnlockArtifactsWorker do
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
+ context 'when ci ref exists for project' do
+ let!(:ci_ref) { create(:ci_ref, ref_path: ref, project: project) }
it 'calls the service' do
service = spy(Ci::UnlockArtifactsService)
@@ -40,17 +38,33 @@ RSpec.describe Ci::RefDeleteUnlockArtifactsWorker do
perform
- expect(service).to have_received(:execute)
+ expect(service).to have_received(:execute).with(ci_ref)
end
end
- context 'when ci ref does not exist' do
+ context 'when ci ref does not exist for the given project' do
+ let!(:another_ci_ref) { create(:ci_ref, ref_path: ref) }
+
it 'does not call the service' do
expect(Ci::UnlockArtifactsService).not_to receive(:new)
perform
end
end
+
+ context 'when same ref path exists for a different project' do
+ let!(:another_ci_ref) { create(:ci_ref, ref_path: ref) }
+ let!(:ci_ref) { create(:ci_ref, ref_path: ref, project: project) }
+
+ it 'calls the service with the correct ref_id' do
+ service = spy(Ci::UnlockArtifactsService)
+ expect(Ci::UnlockArtifactsService).to receive(:new).and_return(service)
+
+ perform
+
+ expect(service).to have_received(:execute).with(ci_ref)
+ end
+ end
end
context 'when user does not exist' do