diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-26 12:50:52 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-06-01 07:47:15 +0200 |
commit | b71025c014babf9663e0451ad21eabde91570259 (patch) | |
tree | 743041e1fe0480c44671c95a0f470c62c9ed9d60 /spec | |
parent | 44f2504a811b107a35403d9c0a8b8fce66f502c8 (diff) | |
download | gitlab-ce-b71025c014babf9663e0451ad21eabde91570259.tar.gz |
Add feature tests for improved JIRA settings
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/services/jira_service_spec.rb | 79 | ||||
-rw-r--r-- | spec/features/projects/services/mattermost_slash_command_spec.rb | 6 |
2 files changed, 82 insertions, 3 deletions
diff --git a/spec/features/projects/services/jira_service_spec.rb b/spec/features/projects/services/jira_service_spec.rb new file mode 100644 index 00000000000..d40c332be6f --- /dev/null +++ b/spec/features/projects/services/jira_service_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper' + +feature 'Setup Jira service', :feature, :js do + let(:user) { create(:user) } + let(:project) { create(:empty_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' } + + 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' + end + + before do + project.team << [user, :master] + login_as(user) + + visit namespace_project_settings_integrations_path(project.namespace, 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 + click_link('JIRA') + fill_form + click_button('Test settings and save changes') + wait_for_ajax + + expect(page).to have_content('JIRA activated.') + expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + end + end + + context 'when Jira connection test fails' do + before do + WebMock.stub_request(:get, project_url).to_return(status: 401) + end + + it 'activates the JIRA service' do + click_link('JIRA') + fill_form + click_button('Test settings and save changes') + wait_for_ajax + + expect(page).to have_content('Test failed.Save anyway') + + click_on('Save anyway') + wait_for_ajax + + expect(page).to have_content('JIRA activated.') + expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + end + end + end + + describe 'user sets Jira Service but keeps it non active' do + context 'when Jira connection test succeeds' do + it 'activates the JIRA service' do + click_link('JIRA') + fill_form(false) + 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)) + end + end + end +end diff --git a/spec/features/projects/services/mattermost_slash_command_spec.rb b/spec/features/projects/services/mattermost_slash_command_spec.rb index bb12f64a552..1fe82222e59 100644 --- a/spec/features/projects/services/mattermost_slash_command_spec.rb +++ b/spec/features/projects/services/mattermost_slash_command_spec.rb @@ -28,7 +28,7 @@ feature 'Setup Mattermost slash commands', :feature, :js do token = ('a'..'z').to_a.join fill_in 'service_token', with: token - click_on 'Save' + click_on 'Save changes' expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) expect(page).to have_content('Mattermost slash commands settings saved, but not activated.') @@ -39,10 +39,10 @@ feature 'Setup Mattermost slash commands', :feature, :js do fill_in 'service_token', with: token check 'service_active' - click_on 'Save' + click_on 'Save changes' expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) - expect(page).to have_content(' Mattermost slash commands activated.') + expect(page).to have_content('Mattermost slash commands activated.') end it 'shows the add to mattermost button' do |