2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
describe 'Maintainer deletes tag' do
|
2016-06-02 11:05:42 +05:30
|
|
|
let(:user) { create(:user) }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, :repository, namespace: user.namespace) }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
|
|
|
visit project_tags_path(project)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'from the tags list page', :js do
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'deletes the tag' do
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(page).to have_content 'v1.1.0'
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
delete_first_tag
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
expect(page).not_to have_content 'v1.1.0'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'from a specific tag page' do
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'deletes the tag' do
|
2016-06-02 11:05:42 +05:30
|
|
|
click_on 'v1.0.0'
|
|
|
|
expect(current_path).to eq(
|
2017-09-10 17:25:29 +05:30
|
|
|
project_tag_path(project, 'v1.0.0'))
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
click_on 'Delete tag'
|
|
|
|
|
|
|
|
expect(current_path).to eq(
|
2017-09-10 17:25:29 +05:30
|
|
|
project_tags_path(project))
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(page).not_to have_content 'v1.0.0'
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'when pre-receive hook fails', :js do
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
|
|
|
allow_any_instance_of(Gitlab::GitalyClient::OperationService).to receive(:rm_tag)
|
2019-05-30 16:15:17 +05:30
|
|
|
.and_raise(Gitlab::Git::PreReceiveError, 'Do not delete tags')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'shows the error message' do
|
|
|
|
delete_first_tag
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(page).to have_content('Do not delete tags')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_first_tag
|
|
|
|
page.within('.content') do
|
2018-03-17 18:26:18 +05:30
|
|
|
accept_confirm { first('.btn-remove').click }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|