diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/models/onboarding/completion_spec.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/models/onboarding/completion_spec.rb')
-rw-r--r-- | spec/models/onboarding/completion_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/models/onboarding/completion_spec.rb b/spec/models/onboarding/completion_spec.rb new file mode 100644 index 00000000000..e1fad4255bc --- /dev/null +++ b/spec/models/onboarding/completion_spec.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Onboarding::Completion do + describe '#percentage' do + let(:completed_actions) { {} } + let!(:onboarding_progress) { create(:onboarding_progress, namespace: namespace, **completed_actions) } + let(:tracked_action_columns) do + [ + *described_class::ACTION_ISSUE_IDS.keys, + *described_class::ACTION_PATHS, + :security_scan_enabled + ].map { |key| ::Onboarding::Progress.column_name(key) } + end + + let_it_be(:namespace) { create(:namespace) } + + subject { described_class.new(namespace).percentage } + + context 'when no onboarding_progress exists' do + subject { described_class.new(build(:namespace)).percentage } + + 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.index_with { Time.current } + end + + it { is_expected.to eq(100) } + end + + context 'with 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 |