Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_activates_issue_tracker_spec.rb « integrations « projects « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d2c48cb2af0bd10264301e3ecdb0bb47b9edfc13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'User activates issue tracker', :js, feature_category: :integrations do
  include_context 'project integration activation'

  let(:url) { 'http://tracker.example.com' }

  def fill_form(disable: false, skip_new_issue_url: false)
    click_active_checkbox if disable

    fill_in 'service_project_url', with: url
    fill_in 'service_issues_url', with: "#{url}/:id"

    fill_in 'service_new_issue_url', with: url unless skip_new_issue_url
  end

  shared_examples 'external issue tracker activation' do |tracker:, skip_new_issue_url: false, skip_test: false|
    describe 'user sets and activates the integration' do
      context 'when the connection test succeeds' do
        before do
          stub_request(:head, url).to_return(headers: { 'Content-Type' => 'application/json' })

          visit_project_integration(tracker)
          fill_form(skip_new_issue_url: skip_new_issue_url)

          if skip_test
            click_save_integration
          else
            click_test_then_save_integration(expect_test_to_fail: false)
          end
        end

        it 'activates the integration' do
          expect(page).to have_content("#{tracker} settings saved and active.")
          expect(page).to have_current_path(edit_project_settings_integration_path(project, tracker.parameterize(separator: '_')), ignore_query: true)
        end

        it 'shows the link in the menu' do
          page.within('.nav-sidebar') do
            expect(page).to have_link(tracker, href: url)
          end
        end
      end

      context 'when the connection test fails' do
        it 'activates the integration' do
          stub_request(:head, url).to_raise(Gitlab::HTTP::Error)

          visit_project_integration(tracker)
          fill_form(skip_new_issue_url: skip_new_issue_url)

          if skip_test
            click_button('Save changes')
          else
            click_test_then_save_integration
          end

          expect(page).to have_content("#{tracker} settings saved and active.")
          expect(page).to have_current_path(edit_project_settings_integration_path(project, tracker.parameterize(separator: '_')), ignore_query: true)
        end
      end
    end

    describe 'user disables the integration' do
      before do
        visit_project_integration(tracker)
        fill_form(disable: true, skip_new_issue_url: skip_new_issue_url)

        click_button('Save changes')
      end

      it 'saves but does not activate the integration' do
        expect(page).to have_content("#{tracker} settings saved, but not active.")
        expect(page).to have_current_path(edit_project_settings_integration_path(project, tracker.parameterize(separator: '_')), ignore_query: true)
      end

      it 'does not show the external tracker link in the menu' do
        page.within('.nav-sidebar') do
          expect(page).not_to have_link(tracker, href: url)
        end
      end
    end
  end

  it_behaves_like 'external issue tracker activation', tracker: 'Redmine'
  it_behaves_like 'external issue tracker activation', tracker: 'YouTrack', skip_new_issue_url: true
  it_behaves_like 'external issue tracker activation', tracker: 'Bugzilla'
  it_behaves_like 'external issue tracker activation', tracker: 'Custom issue tracker'
  it_behaves_like 'external issue tracker activation', tracker: 'EWM', skip_test: true
end