diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-19 14:50:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-19 14:50:12 +0300 |
commit | 6cd5b7dbfaa4ff630ecbbfe351a1faac5fc71a8d (patch) | |
tree | d3563b9f60936c18a02185e2e53b424bb1b83539 /spec/controllers | |
parent | b3e0658cb1fbc7c8e7dd381467c656f2e675ee46 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/registry/tags_controller_spec.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/spec/controllers/projects/registry/tags_controller_spec.rb b/spec/controllers/projects/registry/tags_controller_spec.rb index c6e063d8229..8da0d217e9e 100644 --- a/spec/controllers/projects/registry/tags_controller_spec.rb +++ b/spec/controllers/projects/registry/tags_controller_spec.rb @@ -10,6 +10,8 @@ describe Projects::Registry::TagsController do create(:container_repository, name: 'image', project: project) end + let(:service) { double('service') } + before do sign_in(user) stub_container_registry_config(enabled: true) @@ -84,17 +86,17 @@ describe Projects::Registry::TagsController do context 'when there is matching tag present' do before do - stub_container_registry_tags(repository: repository.path, tags: %w[rc1 test.]) + stub_container_registry_tags(repository: repository.path, tags: %w[rc1], with_manifest: true) end it 'makes it possible to delete regular tag' do - expect_any_instance_of(ContainerRegistry::Tag).to receive(:delete) + expect_delete_tags(%w[rc1]) destroy_tag('rc1') end it 'makes it possible to delete a tag that ends with a dot' do - expect_any_instance_of(ContainerRegistry::Tag).to receive(:delete) + expect_delete_tags(%w[test.]) destroy_tag('test.') end @@ -125,11 +127,12 @@ describe Projects::Registry::TagsController do stub_container_registry_tags(repository: repository.path, tags: %w[rc1 test.]) end + let(:tags) { %w[tc1 test.] } + it 'makes it possible to delete tags in bulk' do - allow_any_instance_of(ContainerRegistry::Tag).to receive(:delete) { |*args| ContainerRegistry::Tag.delete(*args) } - expect(ContainerRegistry::Tag).to receive(:delete).exactly(2).times + expect_delete_tags(tags) - bulk_destroy_tags(['rc1', 'test.']) + bulk_destroy_tags(tags) end end end @@ -146,4 +149,9 @@ describe Projects::Registry::TagsController do format: :json end end + + def expect_delete_tags(tags, status = :success) + expect(service).to receive(:execute).with(repository) { { status: status } } + expect(Projects::ContainerRepository::DeleteTagsService).to receive(:new).with(repository.project, user, tags: tags) { service } + end end |