2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
describe 'Developer deletes tag' do
|
2016-06-02 11:05:42 +05:30
|
|
|
let(:user) { create(:user) }
|
2019-09-30 21:07:59 +05:30
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, :repository, namespace: group) }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
before do
|
2019-09-30 21:07:59 +05:30
|
|
|
project.add_developer(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'
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
delete_tag 'v1.1.0'
|
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-07-07 11:18:12 +05:30
|
|
|
.and_raise(Gitlab::Git::PreReceiveError, 'GitLab: 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
|
2019-12-04 20:38:33 +05:30
|
|
|
delete_tag 'v1.1.0'
|
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
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
def delete_tag(tag)
|
2017-08-17 22:00:37 +05:30
|
|
|
page.within('.content') do
|
2019-12-04 20:38:33 +05:30
|
|
|
accept_confirm { find("li > .row-fixed-content.controls a.btn-remove[href='/#{project.full_path}/-/tags/#{tag}']").click }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|