debian-mirror-gitlab/spec/features/projects/integrations/user_activates_issue_tracker_spec.rb

93 lines
3.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-27 19:54:05 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'User activates issue tracker', :js do
2022-04-04 11:22:00 +05:30
include_context 'project integration activation'
2018-03-27 19:54:05 +05:30
let(:url) { 'http://tracker.example.com' }
2020-05-24 23:13:21 +05:30
def fill_form(disable: false, skip_new_issue_url: false)
2020-11-24 15:15:51 +05:30
click_active_checkbox if disable
2018-03-27 19:54:05 +05:30
fill_in 'service_project_url', with: url
fill_in 'service_issues_url', with: "#{url}/:id"
2019-07-07 11:18:12 +05:30
2020-05-24 23:13:21 +05:30
fill_in 'service_new_issue_url', with: url unless skip_new_issue_url
2018-03-27 19:54:05 +05:30
end
2020-11-24 15:15:51 +05:30
shared_examples 'external issue tracker activation' do |tracker:, skip_new_issue_url: false, skip_test: false|
2022-04-04 11:22:00 +05:30
describe 'user sets and activates the integration' do
2018-03-27 19:54:05 +05:30
context 'when the connection test succeeds' do
before do
stub_request(:head, url).to_return(headers: { 'Content-Type' => 'application/json' })
2020-05-24 23:13:21 +05:30
visit_project_integration(tracker)
fill_form(skip_new_issue_url: skip_new_issue_url)
2019-07-07 11:18:12 +05:30
2020-11-24 15:15:51 +05:30
if skip_test
click_save_integration
else
click_test_then_save_integration(expect_test_to_fail: false)
end
2018-03-27 19:54:05 +05:30
end
2022-04-04 11:22:00 +05:30
it 'activates the integration' do
2020-11-24 15:15:51 +05:30
expect(page).to have_content("#{tracker} settings saved and active.")
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(edit_project_integration_path(project, tracker.parameterize(separator: '_')), ignore_query: true)
2018-03-27 19:54:05 +05:30
end
it 'shows the link in the menu' do
page.within('.nav-sidebar') do
expect(page).to have_link(tracker, href: url)
end
end
end
context 'when the connection test fails' do
2022-04-04 11:22:00 +05:30
it 'activates the integration' do
2019-10-12 21:52:04 +05:30
stub_request(:head, url).to_raise(Gitlab::HTTP::Error)
2018-03-27 19:54:05 +05:30
2020-05-24 23:13:21 +05:30
visit_project_integration(tracker)
fill_form(skip_new_issue_url: skip_new_issue_url)
2019-07-07 11:18:12 +05:30
2020-11-24 15:15:51 +05:30
if skip_test
click_button('Save changes')
else
click_test_then_save_integration
end
2018-03-27 19:54:05 +05:30
2020-11-24 15:15:51 +05:30
expect(page).to have_content("#{tracker} settings saved and active.")
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(edit_project_integration_path(project, tracker.parameterize(separator: '_')), ignore_query: true)
2018-03-27 19:54:05 +05:30
end
end
end
2022-04-04 11:22:00 +05:30
describe 'user disables the integration' do
2018-03-27 19:54:05 +05:30
before do
2020-05-24 23:13:21 +05:30
visit_project_integration(tracker)
fill_form(disable: true, skip_new_issue_url: skip_new_issue_url)
2019-07-07 11:18:12 +05:30
2018-03-27 19:54:05 +05:30
click_button('Save changes')
end
2022-04-04 11:22:00 +05:30
it 'saves but does not activate the integration' do
2020-11-24 15:15:51 +05:30
expect(page).to have_content("#{tracker} settings saved, but not active.")
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(edit_project_integration_path(project, tracker.parameterize(separator: '_')), ignore_query: true)
2018-03-27 19:54:05 +05:30
end
it 'does not show the external tracker link in the menu' do
page.within('.nav-sidebar') do
expect(page).not_to have_link(tracker, href: url)
end
end
end
end
it_behaves_like 'external issue tracker activation', tracker: 'Redmine'
2019-07-07 11:18:12 +05:30
it_behaves_like 'external issue tracker activation', tracker: 'YouTrack', skip_new_issue_url: true
2018-03-27 19:54:05 +05:30
it_behaves_like 'external issue tracker activation', tracker: 'Bugzilla'
2021-06-08 01:23:25 +05:30
it_behaves_like 'external issue tracker activation', tracker: 'Custom issue tracker'
2020-11-24 15:15:51 +05:30
it_behaves_like 'external issue tracker activation', tracker: 'EWM', skip_test: true
2018-03-27 19:54:05 +05:30
end