diff options
Diffstat (limited to 'spec/features/projects/services/jira_service_spec.rb')
-rw-r--r-- | spec/features/projects/services/jira_service_spec.rb | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/spec/features/projects/services/jira_service_spec.rb b/spec/features/projects/services/jira_service_spec.rb index c96d87e5708..65e3a487d4b 100644 --- a/spec/features/projects/services/jira_service_spec.rb +++ b/spec/features/projects/services/jira_service_spec.rb @@ -1,18 +1,17 @@ require 'spec_helper' -feature 'Setup Jira service', :feature, :js do +feature 'Setup Jira service', :js do let(:user) { create(:user) } - let(:project) { create(:empty_project) } + let(:project) { create(:project) } let(:service) { project.create_jira_service } let(:url) { 'http://jira.example.com' } - let(:project_url) { 'http://username:password@jira.example.com/rest/api/2/project/GitLabProject' } + let(:test_url) { 'http://jira.example.com/rest/api/2/serverInfo' } def fill_form(active = true) check 'Active' if active fill_in 'service_url', with: url - fill_in 'service_project_key', with: 'GitLabProject' fill_in 'service_username', with: 'username' fill_in 'service_password', with: 'password' fill_in 'service_jira_issue_transition_id', with: '25' @@ -20,33 +19,28 @@ feature 'Setup Jira service', :feature, :js do before do project.team << [user, :master] - login_as(user) + sign_in(user) - visit namespace_project_settings_integrations_path(project.namespace, project) + visit project_settings_integrations_path(project) end describe 'user sets and activates Jira Service' do context 'when Jira connection test succeeds' do - before do - WebMock.stub_request(:get, project_url) - end - it 'activates the JIRA service' do + server_info = { key: 'value' }.to_json + WebMock.stub_request(:get, test_url).with(basic_auth: %w(username password)).to_return(body: server_info) + click_link('JIRA') fill_form click_button('Test settings and save changes') wait_for_requests expect(page).to have_content('JIRA activated.') - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) end end context 'when Jira connection test fails' do - before do - WebMock.stub_request(:get, project_url).to_return(status: 401) - end - it 'shows errors when some required fields are not filled in' do click_link('JIRA') @@ -60,19 +54,22 @@ feature 'Setup Jira service', :feature, :js do end it 'activates the JIRA service' do + WebMock.stub_request(:get, test_url).with(basic_auth: %w(username password)) + .to_raise(JIRA::HTTPError.new(double(message: 'message'))) + click_link('JIRA') fill_form click_button('Test settings and save changes') wait_for_requests - expect(find('.flash-container-page')).to have_content 'Test failed.' + expect(find('.flash-container-page')).to have_content 'Test failed. message' expect(find('.flash-container-page')).to have_content 'Save anyway' find('.flash-alert .flash-action').trigger('click') wait_for_requests expect(page).to have_content('JIRA activated.') - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) end end end @@ -85,7 +82,7 @@ feature 'Setup Jira service', :feature, :js do click_button('Save changes') expect(page).to have_content('JIRA settings saved, but not activated.') - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) end end end |