summaryrefslogtreecommitdiff
path: root/spec/views/profiles/preferences/show.html.haml_spec.rb
blob: 5acfbfb9db112f13702461333afb4788e11c6b85 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'profiles/preferences/show' do
  using RSpec::Parameterized::TableSyntax

  let_it_be(:user) { build(:user) }

  before do
    assign(:user, user)
    allow(controller).to receive(:current_user).and_return(user)
  end

  context 'behavior' do
    before do
      render
    end

    it 'has option for Render whitespace characters in the Web IDE' do
      expect(rendered).to have_unchecked_field('Render whitespace characters in the Web IDE')
    end
  end

  context 'sourcegraph' do
    def have_sourcegraph_field(*args)
      have_field('user_sourcegraph_enabled', *args)
    end

    def have_integrations_section
      have_css('.profile-settings-sidebar', { text: 'Integrations' })
    end

    before do
      stub_feature_flags(sourcegraph: sourcegraph_feature)
      stub_application_setting(sourcegraph_enabled: sourcegraph_enabled)
    end

    context 'when not fully enabled' do
      where(:feature, :admin_enabled) do
        false | false
        false | true
        true | false
      end

      with_them do
        let(:sourcegraph_feature) { feature }
        let(:sourcegraph_enabled) { admin_enabled }

        before do
          render
        end

        it 'does not display sourcegraph field' do
          expect(rendered).not_to have_sourcegraph_field
        end

        it 'does not display Integration Settings' do
          expect(rendered).not_to have_integrations_section
        end
      end
    end

    context 'when fully enabled' do
      let(:sourcegraph_feature) { true }
      let(:sourcegraph_enabled) { true }

      before do
        render
      end

      it 'displays the sourcegraph field' do
        expect(rendered).to have_sourcegraph_field
      end

      it 'displays the integrations section' do
        expect(rendered).to have_integrations_section
      end
    end
  end
end