2017-05-26 06:50:52 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-22 00:42:52 -04:00
|
|
|
describe 'User activates Jira', :js do
|
2017-05-26 06:50:52 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-05-26 06:50:52 -04:00
|
|
|
|
|
|
|
let(:url) { 'http://jira.example.com' }
|
2017-07-25 11:25:41 -04:00
|
|
|
let(:test_url) { 'http://jira.example.com/rest/api/2/serverInfo' }
|
2017-05-26 06:50:52 -04:00
|
|
|
|
|
|
|
def fill_form(active = true)
|
|
|
|
check 'Active' if active
|
|
|
|
|
|
|
|
fill_in 'service_url', with: url
|
|
|
|
fill_in 'service_username', with: 'username'
|
|
|
|
fill_in 'service_password', with: 'password'
|
|
|
|
fill_in 'service_jira_issue_transition_id', with: '25'
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-05-26 06:50:52 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_settings_integrations_path(project)
|
2017-05-26 06:50:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'user sets and activates Jira Service' do
|
|
|
|
context 'when Jira connection test succeeds' do
|
2018-02-09 05:18:53 -05:00
|
|
|
before do
|
2017-07-25 11:25:41 -04:00
|
|
|
server_info = { key: 'value' }.to_json
|
|
|
|
WebMock.stub_request(:get, test_url).with(basic_auth: %w(username password)).to_return(body: server_info)
|
|
|
|
|
2017-05-26 06:50:52 -04:00
|
|
|
click_link('JIRA')
|
|
|
|
fill_form
|
|
|
|
click_button('Test settings and save changes')
|
2017-05-29 05:29:43 -04:00
|
|
|
wait_for_requests
|
2018-02-09 05:18:53 -05:00
|
|
|
end
|
2017-05-26 06:50:52 -04:00
|
|
|
|
2018-02-09 05:18:53 -05:00
|
|
|
it 'activates the JIRA service' do
|
2017-05-26 06:50:52 -04:00
|
|
|
expect(page).to have_content('JIRA activated.')
|
2017-07-06 12:20:50 -04:00
|
|
|
expect(current_path).to eq(project_settings_integrations_path(project))
|
2017-05-26 06:50:52 -04:00
|
|
|
end
|
2018-02-09 05:18:53 -05:00
|
|
|
|
|
|
|
it 'shows the JIRA link in the menu' do
|
|
|
|
page.within('.nav-sidebar') do
|
|
|
|
expect(page).to have_link('JIRA', href: url)
|
|
|
|
end
|
|
|
|
end
|
2017-05-26 06:50:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when Jira connection test fails' do
|
2017-05-30 08:53:01 -04:00
|
|
|
it 'shows errors when some required fields are not filled in' do
|
|
|
|
click_link('JIRA')
|
|
|
|
|
|
|
|
check 'Active'
|
|
|
|
fill_in 'service_password', with: 'password'
|
|
|
|
click_button('Test settings and save changes')
|
|
|
|
|
|
|
|
page.within('.service-settings') do
|
|
|
|
expect(page).to have_content('This field is required.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-26 06:50:52 -04:00
|
|
|
it 'activates the JIRA service' do
|
2017-07-25 11:25:41 -04:00
|
|
|
WebMock.stub_request(:get, test_url).with(basic_auth: %w(username password))
|
|
|
|
.to_raise(JIRA::HTTPError.new(double(message: 'message')))
|
|
|
|
|
2017-05-26 06:50:52 -04:00
|
|
|
click_link('JIRA')
|
|
|
|
fill_form
|
|
|
|
click_button('Test settings and save changes')
|
2017-05-29 05:29:43 -04:00
|
|
|
wait_for_requests
|
2017-05-26 06:50:52 -04:00
|
|
|
|
2017-07-26 03:57:56 -04:00
|
|
|
expect(find('.flash-container-page')).to have_content 'Test failed. message'
|
2017-06-02 08:35:47 -04:00
|
|
|
expect(find('.flash-container-page')).to have_content 'Save anyway'
|
2017-05-26 06:50:52 -04:00
|
|
|
|
2017-06-17 02:08:27 -04:00
|
|
|
find('.flash-alert .flash-action').click
|
2017-05-29 05:29:43 -04:00
|
|
|
wait_for_requests
|
2017-05-26 06:50:52 -04:00
|
|
|
|
|
|
|
expect(page).to have_content('JIRA activated.')
|
2017-07-06 12:20:50 -04:00
|
|
|
expect(current_path).to eq(project_settings_integrations_path(project))
|
2017-05-26 06:50:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-02 07:44:04 -04:00
|
|
|
describe 'user sets Jira Service but keeps it disabled' do
|
2018-02-09 05:18:53 -05:00
|
|
|
before do
|
|
|
|
click_link('JIRA')
|
|
|
|
fill_form(false)
|
|
|
|
click_button('Save changes')
|
|
|
|
end
|
2017-05-26 06:50:52 -04:00
|
|
|
|
2018-02-09 05:18:53 -05:00
|
|
|
it 'saves but does not activate the JIRA service' do
|
|
|
|
expect(page).to have_content('JIRA settings saved, but not activated.')
|
|
|
|
expect(current_path).to eq(project_settings_integrations_path(project))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show the JIRA link in the menu' do
|
|
|
|
page.within('.nav-sidebar') do
|
|
|
|
expect(page).not_to have_link('JIRA', href: url)
|
2017-05-26 06:50:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|