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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

149 lines
5 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'User activates Jira', :js, feature_category: :integrations do
2022-04-04 11:22:00 +05:30
include_context 'project integration activation'
include_context 'project integration Jira context'
2017-09-10 17:25:29 +05:30
2021-04-29 21:17:54 +05:30
before do
stub_request(:get, test_url).to_return(body: { key: 'value' }.to_json)
end
2022-04-04 11:22:00 +05:30
describe 'user tests Jira integration' do
2017-09-10 17:25:29 +05:30
context 'when Jira connection test succeeds' do
2018-03-27 19:54:05 +05:30
before do
2020-05-24 23:13:21 +05:30
visit_project_integration('Jira')
2017-09-10 17:25:29 +05:30
fill_form
2020-11-24 15:15:51 +05:30
click_test_then_save_integration(expect_test_to_fail: false)
2018-03-27 19:54:05 +05:30
end
2017-09-10 17:25:29 +05:30
2022-04-04 11:22:00 +05:30
it 'activates the Jira integration' do
2020-11-24 15:15:51 +05:30
expect(page).to have_content('Jira settings saved and active.')
2022-07-23 23:45:48 +05:30
expect(page).to have_current_path(edit_project_settings_integration_path(project, :jira), ignore_query: true)
2017-09-10 17:25:29 +05:30
end
2018-03-27 19:54:05 +05:30
2020-07-28 23:09:34 +05:30
unless Gitlab.ee?
it 'adds Jira link to sidebar menu' do
page.within('.nav-sidebar') do
2022-01-26 12:08:38 +05:30
expect(page).not_to have_link('Jira issues', visible: false)
2020-07-28 23:09:34 +05:30
expect(page).not_to have_link('Open Jira', href: url, visible: false)
expect(page).to have_link('Jira', href: url)
end
2018-03-27 19:54:05 +05:30
end
end
2017-09-10 17:25:29 +05:30
end
context 'when Jira connection test fails' do
it 'shows errors when some required fields are not filled in' do
2020-05-24 23:13:21 +05:30
visit_project_integration('Jira')
2017-09-10 17:25:29 +05:30
fill_in 'service_password', with: 'password'
2020-05-24 23:13:21 +05:30
click_test_integration
2017-09-10 17:25:29 +05:30
2022-03-02 08:16:31 +05:30
page.within('[data-testid="integration-settings-form"]') do
2017-09-10 17:25:29 +05:30
expect(page).to have_content('This field is required.')
end
end
2022-04-04 11:22:00 +05:30
it 'activates the Jira integration' do
2020-05-24 23:13:21 +05:30
stub_request(:get, test_url).with(basic_auth: %w(username password))
2017-09-10 17:25:29 +05:30
.to_raise(JIRA::HTTPError.new(double(message: 'message')))
2020-05-24 23:13:21 +05:30
visit_project_integration('Jira')
2017-09-10 17:25:29 +05:30
fill_form
2020-05-24 23:13:21 +05:30
click_test_then_save_integration
2017-09-10 17:25:29 +05:30
2020-11-24 15:15:51 +05:30
expect(page).to have_content('Jira settings saved and active.')
2022-07-23 23:45:48 +05:30
expect(page).to have_current_path(edit_project_settings_integration_path(project, :jira), ignore_query: true)
2017-09-10 17:25:29 +05:30
end
end
end
2022-04-04 11:22:00 +05:30
describe 'user disables the Jira integration' do
2022-07-23 23:45:48 +05:30
include JiraIntegrationHelpers
2020-11-24 15:15:51 +05:30
2018-03-27 19:54:05 +05:30
before do
2021-09-30 23:02:18 +05:30
stub_jira_integration_test
2020-05-24 23:13:21 +05:30
visit_project_integration('Jira')
fill_form(disable: true)
2020-11-24 15:15:51 +05:30
click_save_integration
2018-03-27 19:54:05 +05:30
end
2017-09-10 17:25:29 +05:30
2022-04-04 11:22:00 +05:30
it 'saves but does not activate the Jira integration' do
2020-11-24 15:15:51 +05:30
expect(page).to have_content('Jira settings saved, but not active.')
2022-07-23 23:45:48 +05:30
expect(page).to have_current_path(edit_project_settings_integration_path(project, :jira), ignore_query: true)
2018-03-27 19:54:05 +05:30
end
2019-09-30 21:07:59 +05:30
it 'does not show the Jira link in the menu' do
2018-03-27 19:54:05 +05:30
page.within('.nav-sidebar') do
2019-09-30 21:07:59 +05:30
expect(page).not_to have_link('Jira', href: url)
2017-09-10 17:25:29 +05:30
end
end
end
2021-04-29 21:17:54 +05:30
describe 'issue transition settings' do
it 'using custom transitions' do
visit_project_integration('Jira')
expect(page).to have_field('Enable Jira transitions', checked: false)
check 'Enable Jira transitions'
expect(page).to have_field('Move to Done', checked: true)
fill_form
choose 'Use custom transitions'
click_save_integration
within '[data-testid="issue-transition-mode"]' do
expect(page).to have_content('This field is required.')
end
fill_in 'service[jira_issue_transition_id]', with: '1, 2, 3'
click_save_integration
expect(page).to have_content('Jira settings saved and active.')
2021-09-30 23:02:18 +05:30
expect(project.reload.jira_integration.data_fields).to have_attributes(
2021-04-29 21:17:54 +05:30
jira_issue_transition_automatic: false,
jira_issue_transition_id: '1, 2, 3'
)
end
it 'using automatic transitions' do
2021-09-30 23:02:18 +05:30
create(:jira_integration, project: project, jira_issue_transition_automatic: false, jira_issue_transition_id: '1, 2, 3')
2021-04-29 21:17:54 +05:30
visit_project_integration('Jira')
expect(page).to have_field('Enable Jira transitions', checked: true)
expect(page).to have_field('Use custom transitions', checked: true)
expect(page).to have_field('service[jira_issue_transition_id]', with: '1, 2, 3')
choose 'Move to Done'
click_save_integration
expect(page).to have_content('Jira settings saved and active.')
2021-09-30 23:02:18 +05:30
expect(project.reload.jira_integration.data_fields).to have_attributes(
2021-04-29 21:17:54 +05:30
jira_issue_transition_automatic: true,
jira_issue_transition_id: ''
)
end
it 'disabling issue transitions' do
2021-09-30 23:02:18 +05:30
create(:jira_integration, project: project, jira_issue_transition_automatic: true, jira_issue_transition_id: '1, 2, 3')
2021-04-29 21:17:54 +05:30
visit_project_integration('Jira')
expect(page).to have_field('Enable Jira transitions', checked: true)
expect(page).to have_field('Move to Done', checked: true)
uncheck 'Enable Jira transitions'
click_save_integration
expect(page).to have_content('Jira settings saved and active.')
2021-09-30 23:02:18 +05:30
expect(project.reload.jira_integration.data_fields).to have_attributes(
2021-04-29 21:17:54 +05:30
jira_issue_transition_automatic: false,
jira_issue_transition_id: ''
)
end
end
2017-09-10 17:25:29 +05:30
end