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

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

require 'spec_helper'

RSpec.describe LearnGitlab::Onboarding do
  describe '#completed_percentage' do
    let(:completed_actions) { {} }
    let(:onboarding_progress) { build(:onboarding_progress, namespace: namespace, **completed_actions) }
    let(:namespace) { create(:namespace) }

    let_it_be(:tracked_action_columns) do
      [
        *described_class::ACTION_ISSUE_IDS.keys,
        *described_class::ACTION_PATHS,
        :security_scan_enabled
      ].map { |key| OnboardingProgress.column_name(key) }
    end

    before do
      expect(OnboardingProgress).to receive(:find_by).with(namespace: namespace).and_return(onboarding_progress)
    end

    subject { described_class.new(namespace).completed_percentage }

    context 'when no onboarding_progress exists' do
      let(:onboarding_progress) { nil }

      it { is_expected.to eq(0) }
    end

    context 'when no action has been completed' do
      it { is_expected.to eq(0) }
    end

    context 'when all tracked actions have been completed' do
      let(:completed_actions) do
        tracked_action_columns.to_h { |action| [action, Time.current] }
      end

      it { is_expected.to eq(100) }
    end

    describe 'security_actions_continuous_onboarding experiment' do
      let(:completed_actions) { Hash[tracked_action_columns.first, Time.current] }

      context 'when control' do
        before do
          stub_experiments(security_actions_continuous_onboarding: :control)
        end

        it { is_expected.to eq(11) }
      end

      context 'when candidate' do
        before do
          stub_experiments(security_actions_continuous_onboarding: :candidate)
        end

        it { is_expected.to eq(9) }
      end
    end
  end
end