Commit b27c4420 authored by Shinya Maeda's avatar Shinya Maeda

Destroy releases when delete a tag

ok

ok

ok

ok
parent b4de23a6
...@@ -5,7 +5,6 @@ module Releases ...@@ -5,7 +5,6 @@ module Releases
include Releases::Concerns include Releases::Concerns
def execute def execute
return error('Tag does not exist', 404) unless existing_tag
return error('Release does not exist', 404) unless release return error('Release does not exist', 404) unless release
return error('Access Denied', 403) unless allowed? return error('Access Denied', 403) unless allowed?
......
---
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 ...@@ -28,13 +28,11 @@ describe Releases::DestroyService do
end end
end end
context 'when tag is not found' do context 'when tag does not exist in the repository' do
let(:tag) { 'v1.1.1' } let(:tag) { 'v1.1.1' }
it 'returns an error' do it 'removes the orphaned release' do
is_expected.to include(status: :error, expect { subject }.to change { project.releases.count }.by(-1)
message: 'Tag does not exist',
http_status: 404)
end end
end end
......
...@@ -7,11 +7,27 @@ describe Tags::DestroyService do ...@@ -7,11 +7,27 @@ describe Tags::DestroyService do
let(:service) { described_class.new(project, user) } let(:service) { described_class.new(project, user) }
describe '#execute' do describe '#execute' do
subject { service.execute(tag_name) }
it 'removes the tag' do it 'removes the tag' do
expect(repository).to receive(:before_remove_tag) expect(repository).to receive(:before_remove_tag)
expect(service).to receive(:success) expect(service).to receive(:success)
service.execute('v1.1.0') service.execute('v1.1.0')
end 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
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment