Destroy releases when delete a tag
ok ok ok ok
This commit is contained in:
parent
b4de23a687
commit
b27c4420c9
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