2016-04-20 12:34:28 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
feature 'Master deletes tag' do
|
2016-04-20 12:34:28 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :repository, namespace: user.namespace) }
|
2016-04-20 12:34:28 +00:00
|
|
|
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_master(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_tags_path(project)
|
2016-04-20 12:34:28 +00:00
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'from the tags list page', :js do
|
2016-04-20 12:34:28 +00:00
|
|
|
scenario 'deletes the tag' do
|
|
|
|
expect(page).to have_content 'v1.1.0'
|
|
|
|
|
2017-03-13 17:12:32 +00:00
|
|
|
delete_first_tag
|
2016-04-20 12:34:28 +00:00
|
|
|
|
|
|
|
expect(page).not_to have_content 'v1.1.0'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'from a specific tag page' do
|
|
|
|
scenario 'deletes the tag' do
|
|
|
|
click_on 'v1.0.0'
|
|
|
|
expect(current_path).to eq(
|
2017-07-06 16:20:50 +00:00
|
|
|
project_tag_path(project, 'v1.0.0'))
|
2016-04-20 12:34:28 +00:00
|
|
|
|
|
|
|
click_on 'Delete tag'
|
|
|
|
|
|
|
|
expect(current_path).to eq(
|
2017-07-06 16:20:50 +00:00
|
|
|
project_tags_path(project))
|
2016-04-20 12:34:28 +00:00
|
|
|
expect(page).not_to have_content 'v1.0.0'
|
|
|
|
end
|
|
|
|
end
|
2017-03-13 17:12:32 +00:00
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'when pre-receive hook fails', :js do
|
2017-09-20 10:11:51 +00:00
|
|
|
context 'when Gitaly operation_user_delete_tag feature is enabled' do
|
|
|
|
before do
|
|
|
|
allow_any_instance_of(Gitlab::GitalyClient::OperationService).to receive(:rm_tag)
|
|
|
|
.and_raise(Gitlab::Git::HooksService::PreReceiveError, 'Do not delete tags')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'shows the error message' do
|
|
|
|
delete_first_tag
|
|
|
|
|
|
|
|
expect(page).to have_content('Do not delete tags')
|
|
|
|
end
|
2017-03-13 17:12:32 +00:00
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'when Gitaly operation_user_delete_tag feature is disabled', :skip_gitaly_mock do
|
2017-09-20 10:11:51 +00:00
|
|
|
before do
|
|
|
|
allow_any_instance_of(Gitlab::Git::HooksService).to receive(:execute)
|
|
|
|
.and_raise(Gitlab::Git::HooksService::PreReceiveError, 'Do not delete tags')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'shows the error message' do
|
|
|
|
delete_first_tag
|
2017-03-13 17:12:32 +00:00
|
|
|
|
2017-09-20 10:11:51 +00:00
|
|
|
expect(page).to have_content('Do not delete tags')
|
|
|
|
end
|
2017-03-13 17:12:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_first_tag
|
|
|
|
page.within('.content') do
|
2017-10-24 14:55:30 +00:00
|
|
|
accept_confirm { first('.btn-remove').click }
|
2017-03-13 17:12:32 +00:00
|
|
|
end
|
|
|
|
end
|
2016-04-20 12:34:28 +00:00
|
|
|
end
|