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

one_trust_helper_spec.rb « helpers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 85c38885304e617066fb3c31f5c991ef3c7daf25 (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
# frozen_string_literal: true

require "spec_helper"

RSpec.describe OneTrustHelper do
  describe '#one_trust_enabled?' do
    let(:user) { nil }

    before do
      stub_config(extra: { one_trust_id: SecureRandom.uuid })
      allow(helper).to receive(:current_user).and_return(user)
    end

    subject(:one_trust_enabled?) { helper.one_trust_enabled? }

    context 'with ecomm_instrumentation feature flag disabled' do
      before do
        stub_feature_flags(ecomm_instrumentation: false)
      end

      context 'when id is set and no user is set' do
        let(:user) { instance_double('User') }

        it { is_expected.to be_falsey }
      end
    end

    context 'with ecomm_instrumentation feature flag enabled' do
      context 'when current user is set' do
        let(:user) { instance_double('User') }

        it { is_expected.to be_falsey }
      end

      context 'when no id is set' do
        before do
          stub_config(extra: {})
        end

        it { is_expected.to be_falsey }
      end

      context 'when id is set and no user is set' do
        it { is_expected.to be_truthy }
      end
    end
  end
end