summaryrefslogtreecommitdiff
path: root/spec/features/projects/services/user_activates_custom_tracker_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/projects/services/user_activates_custom_tracker_spec.rb')
-rw-r--r--spec/features/projects/services/user_activates_custom_tracker_spec.rb86
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/features/projects/services/user_activates_custom_tracker_spec.rb b/spec/features/projects/services/user_activates_custom_tracker_spec.rb
new file mode 100644
index 00000000000..f085b6a1d15
--- /dev/null
+++ b/spec/features/projects/services/user_activates_custom_tracker_spec.rb
@@ -0,0 +1,86 @@
+require 'spec_helper'
+
+describe 'User activates Custom Issue Tracker', :js do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+
+ let(:url) { 'http://tracker.example.com' }
+
+ def fill_form(active = true)
+ check 'Active' if active
+
+ fill_in 'service_project_url', with: url
+ fill_in 'service_issues_url', with: "#{url}/:id"
+ fill_in 'service_new_issue_url', with: url
+ end
+
+ before do
+ project.add_master(user)
+ sign_in(user)
+
+ visit project_settings_integrations_path(project)
+ end
+
+ describe 'user sets and activates Custom Issue Tracker Service' do
+ context 'when Custom Issue Tracker connection test succeeds' do
+ before do
+ stub_request(:head, url).to_return(headers: { 'Content-Type' => 'application/json' })
+
+ click_link('Custom Issue Tracker')
+ fill_form
+ click_button('Test settings and save changes')
+ wait_for_requests
+ end
+
+ it 'activates the Custom Issue Tracker service' do
+ expect(page).to have_content('Custom Issue Tracker activated.')
+ expect(current_path).to eq(project_settings_integrations_path(project))
+ end
+
+ it 'shows the Custom Issue Tracker link in the menu' do
+ page.within('.nav-sidebar') do
+ expect(page).to have_link('Custom Issue Tracker', href: url)
+ end
+ end
+ end
+
+ context 'when Custom Issue Tracker connection test fails' do
+ it 'activates the Custom Issue Tracker service' do
+ stub_request(:head, url).to_raise(HTTParty::Error)
+
+ click_link('Custom Issue Tracker')
+ 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 'Save anyway'
+
+ find('.flash-alert .flash-action').click
+ wait_for_requests
+
+ expect(page).to have_content('Custom Issue Tracker activated.')
+ expect(current_path).to eq(project_settings_integrations_path(project))
+ end
+ end
+ end
+
+ describe 'user sets Custom Issue Tracker Service but keeps it disabled' do
+ before do
+ click_link('Custom Issue Tracker')
+ fill_form(false)
+ click_button('Save changes')
+ end
+
+ it 'saves but does not activate the Custom Issue Tracker service' do
+ expect(page).to have_content('Custom Issue Tracker settings saved, but not activated.')
+ expect(current_path).to eq(project_settings_integrations_path(project))
+ end
+
+ it 'does not show the Custom Issue Tracker link in the menu' do
+ page.within('.nav-sidebar') do
+ expect(page).not_to have_link('Custom Issue Tracker', href: url)
+ end
+ end
+ end
+end