2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
RSpec.describe 'Developer deletes tag', :js 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
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
context 'from the tags list page' 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'
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
container = page.find('.content .flex-row', text: 'v1.1.0')
|
|
|
|
delete_tag container
|
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
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
container = page.find('.nav-controls')
|
|
|
|
delete_tag container
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(current_path).to eq("#{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
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
context 'when pre-receive hook fails' do
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2019-12-26 22:10:19 +05:30
|
|
|
allow_next_instance_of(Gitlab::GitalyClient::OperationService) do |instance|
|
|
|
|
allow(instance).to receive(:rm_tag)
|
|
|
|
.and_raise(Gitlab::Git::PreReceiveError, 'GitLab: Do not delete tags')
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'shows the error message' do
|
2021-01-03 14:25:43 +05:30
|
|
|
container = page.find('.content .flex-row', text: 'v1.1.0')
|
|
|
|
delete_tag container
|
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
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def delete_tag(container)
|
|
|
|
container.find('.js-remove-tag').click
|
|
|
|
|
|
|
|
page.within('.modal') { click_button('Delete tag') }
|
|
|
|
wait_for_requests
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|