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

application_settings_helper_spec.rb « helpers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c2f3e26f97b4ee6b9d19b880eba739a67c8f4596 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# frozen_string_literal: true

require 'spec_helper'

describe ApplicationSettingsHelper do
  context 'when all protocols in use' do
    before do
      stub_application_setting(enabled_git_access_protocol: '')
    end

    it { expect(all_protocols_enabled?).to be_truthy }
    it { expect(http_enabled?).to be_truthy }
    it { expect(ssh_enabled?).to be_truthy }
  end

  context 'when SSH is only in use' do
    before do
      stub_application_setting(enabled_git_access_protocol: 'ssh')
    end

    it { expect(all_protocols_enabled?).to be_falsey }
    it { expect(http_enabled?).to be_falsey }
    it { expect(ssh_enabled?).to be_truthy }
  end

  shared_examples 'when HTTP protocol is in use' do |protocol|
    before do
      allow(Gitlab.config.gitlab).to receive(:protocol).and_return(protocol)
      stub_application_setting(enabled_git_access_protocol: 'http')
    end

    it { expect(all_protocols_enabled?).to be_falsey }
    it { expect(http_enabled?).to be_truthy }
    it { expect(ssh_enabled?).to be_falsey }
  end

  it_behaves_like 'when HTTP protocol is in use', 'https'
  it_behaves_like 'when HTTP protocol is in use', 'http'

  context 'with tracking parameters' do
    it { expect(visible_attributes).to include(*%i(snowplow_collector_hostname snowplow_cookie_domain snowplow_enabled snowplow_app_id)) }
  end

  describe '.integration_expanded?' do
    let(:application_setting) { build(:application_setting) }

    it 'is expanded' do
      application_setting.plantuml_enabled = true
      application_setting.valid?
      helper.instance_variable_set(:@application_setting, application_setting)

      expect(helper.integration_expanded?('plantuml_')).to be_truthy
    end

    it 'is not expanded' do
      application_setting.valid?
      helper.instance_variable_set(:@application_setting, application_setting)

      expect(helper.integration_expanded?('plantuml_')).to be_falsey
    end
  end

  describe '.self_monitoring_project_data' do
    context 'when self monitoring project does not exist' do
      it 'returns create_self_monitoring_project_path' do
        expect(helper.self_monitoring_project_data).to include(
          'create_self_monitoring_project_path' =>
            create_self_monitoring_project_admin_application_settings_path
        )
      end

      it 'returns status_create_self_monitoring_project_path' do
        expect(helper.self_monitoring_project_data).to include(
          'status_create_self_monitoring_project_path' =>
            status_create_self_monitoring_project_admin_application_settings_path
        )
      end

      it 'returns delete_self_monitoring_project_path' do
        expect(helper.self_monitoring_project_data).to include(
          'delete_self_monitoring_project_path' =>
            delete_self_monitoring_project_admin_application_settings_path
        )
      end

      it 'returns status_delete_self_monitoring_project_path' do
        expect(helper.self_monitoring_project_data).to include(
          'status_delete_self_monitoring_project_path' =>
            status_delete_self_monitoring_project_admin_application_settings_path
        )
      end

      it 'returns self_monitoring_project_exists false' do
        expect(helper.self_monitoring_project_data).to include(
          'self_monitoring_project_exists' => "false"
        )
      end

      it 'returns nil for project full_path' do
        expect(helper.self_monitoring_project_data).to include(
          'self_monitoring_project_full_path' => nil
        )
      end
    end

    context 'when self monitoring project exists' do
      let(:project) { build(:project) }

      before do
        stub_application_setting(self_monitoring_project: project)
      end

      it 'returns self_monitoring_project_exists true' do
        expect(helper.self_monitoring_project_data).to include(
          'self_monitoring_project_exists' => "true"
        )
      end

      it 'returns project full_path' do
        expect(helper.self_monitoring_project_data).to include(
          'self_monitoring_project_full_path' => project.full_path
        )
      end
    end
  end
end