diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 18:08:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 18:08:52 +0300 |
commit | 0ab47b994caa80c5587f33dc818626b66cfdafe2 (patch) | |
tree | 5ef3976d2f84e3368903a67ba2dbd87a74b9a43c /spec/workers | |
parent | 1308dc5eb484ab0f8064989fc551ebdb4b1a7976 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/cleanup_container_repository_worker_spec.rb | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/spec/workers/cleanup_container_repository_worker_spec.rb b/spec/workers/cleanup_container_repository_worker_spec.rb index 9be8f882785..1228c2c2d9c 100644 --- a/spec/workers/cleanup_container_repository_worker_spec.rb +++ b/spec/workers/cleanup_container_repository_worker_spec.rb @@ -6,34 +6,49 @@ describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do let(:repository) { create(:container_repository) } let(:project) { repository.project } let(:user) { project.owner } - let(:params) { { key: 'value' } } subject { described_class.new } describe '#perform' do let(:service) { instance_double(Projects::ContainerRepository::CleanupTagsService) } - before do - allow(Projects::ContainerRepository::CleanupTagsService).to receive(:new) - .with(project, user, params).and_return(service) + context 'bulk delete api' do + let(:params) { { key: 'value', 'container_expiration_policy' => false } } + + it 'executes the destroy service' do + expect(Projects::ContainerRepository::CleanupTagsService).to receive(:new) + .with(project, user, params.merge('container_expiration_policy' => false)) + .and_return(service) + expect(service).to receive(:execute) + + subject.perform(user.id, repository.id, params) + end + + it 'does not raise error when user could not be found' do + expect do + subject.perform(-1, repository.id, params) + end.not_to raise_error + end + + it 'does not raise error when repository could not be found' do + expect do + subject.perform(user.id, -1, params) + end.not_to raise_error + end end - it 'executes the destroy service' do - expect(service).to receive(:execute) + context 'container expiration policy' do + let(:params) { { key: 'value', 'container_expiration_policy' => true } } - subject.perform(user.id, repository.id, params) - end + it 'executes the destroy service' do + expect(Projects::ContainerRepository::CleanupTagsService).to receive(:new) + .with(project, nil, params.merge('container_expiration_policy' => true)) + .and_return(service) - it 'does not raise error when user could not be found' do - expect do - subject.perform(-1, repository.id, params) - end.not_to raise_error - end + expect(service).to receive(:execute) - it 'does not raise error when repository could not be found' do - expect do - subject.perform(user.id, -1, params) - end.not_to raise_error + subject.perform(nil, repository.id, params) + end end end end |