summaryrefslogtreecommitdiff
path: root/spec/helpers/onboarding_experiment_helper_spec.rb
blob: 5b7d9b1c2e61a558ed21b73ef0d2d2a452bf256d (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
# frozen_string_literal: true

require 'spec_helper'

describe OnboardingExperimentHelper, type: :helper do
  describe '.allow_access_to_onboarding?' do
    context "when we're not gitlab.com" do
      it 'returns false' do
        allow(::Gitlab).to receive(:com?).and_return(false)

        expect(helper.allow_access_to_onboarding?).to be(false)
      end
    end

    context "when we're gitlab.com" do
      before do
        allow(::Gitlab).to receive(:com?).and_return(true)
      end

      context 'and the :user_onboarding feature is not enabled' do
        it 'returns false' do
          stub_feature_flags(user_onboarding: false)

          expect(helper.allow_access_to_onboarding?).to be(false)
        end
      end

      context 'and the :user_onboarding feature is enabled' do
        it 'returns true' do
          stub_feature_flags(user_onboarding: true)
          allow(helper).to receive(:current_user).and_return(create(:user))

          expect(helper.allow_access_to_onboarding?).to be(true)
        end
      end
    end
  end
end