Merge branch 'delete-release-when-delete-tag' into 'master'
Releases are not automatically deleted when deleting corresponding tag Closes #57980 and #57380 See merge request gitlab-org/gitlab-ce!26530
This commit is contained in:
commit
a5c54bac44
4 changed files with 24 additions and 6 deletions
|
@ -5,7 +5,6 @@ module Releases
|
|||
include Releases::Concerns
|
||||
|
||||
def execute
|
||||
return error('Tag does not exist', 404) unless existing_tag
|
||||
return error('Release does not exist', 404) unless release
|
||||
return error('Access Denied', 403) unless allowed?
|
||||
|
||||
|
|
5
changelogs/unreleased/delete-release-when-delete-tag.yml
Normal file
5
changelogs/unreleased/delete-release-when-delete-tag.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Releases will now be automatically deleted when deleting corresponding tag
|
||||
merge_request: 26530
|
||||
author:
|
||||
type: fixed
|
|
@ -28,13 +28,11 @@ describe Releases::DestroyService do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when tag is not found' do
|
||||
context 'when tag does not exist in the repository' do
|
||||
let(:tag) { 'v1.1.1' }
|
||||
|
||||
it 'returns an error' do
|
||||
is_expected.to include(status: :error,
|
||||
message: 'Tag does not exist',
|
||||
http_status: 404)
|
||||
it 'removes the orphaned release' do
|
||||
expect { subject }.to change { project.releases.count }.by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,11 +7,27 @@ describe Tags::DestroyService do
|
|||
let(:service) { described_class.new(project, user) }
|
||||
|
||||
describe '#execute' do
|
||||
subject { service.execute(tag_name) }
|
||||
|
||||
it 'removes the tag' do
|
||||
expect(repository).to receive(:before_remove_tag)
|
||||
expect(service).to receive(:success)
|
||||
|
||||
service.execute('v1.1.0')
|
||||
end
|
||||
|
||||
context 'when there is an associated release on the tag' do
|
||||
let(:tag) { repository.tags.first }
|
||||
let(:tag_name) { tag.name }
|
||||
|
||||
before do
|
||||
project.add_maintainer(user)
|
||||
create(:release, tag: tag_name, project: project)
|
||||
end
|
||||
|
||||
it 'destroys the release' do
|
||||
expect { subject }.to change { project.releases.count }.by(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue