debian-mirror-gitlab/spec/models/onboarding/completion_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.6 KiB
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
2022-10-11 01:57:18 +05:30
RSpec.describe Onboarding::Completion do
describe '#percentage' do
2021-06-08 01:23:25 +05:30
let(:completed_actions) { {} }
2022-10-11 01:57:18 +05:30
let!(:onboarding_progress) { create(:onboarding_progress, namespace: namespace, **completed_actions) }
let(:tracked_action_columns) do
2022-08-13 15:12:31 +05:30
[
*described_class::ACTION_ISSUE_IDS.keys,
*described_class::ACTION_PATHS,
:security_scan_enabled
2022-10-11 01:57:18 +05:30
].map { |key| ::Onboarding::Progress.column_name(key) }
2021-06-08 01:23:25 +05:30
end
2022-10-11 01:57:18 +05:30
let_it_be(:namespace) { create(:namespace) }
2021-06-08 01:23:25 +05:30
2022-10-11 01:57:18 +05:30
subject { described_class.new(namespace).percentage }
2021-06-08 01:23:25 +05:30
context 'when no onboarding_progress exists' do
2022-10-11 01:57:18 +05:30
subject { described_class.new(build(:namespace)).percentage }
2021-06-08 01:23:25 +05:30
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
2022-10-11 01:57:18 +05:30
tracked_action_columns.index_with { Time.current }
2021-06-08 01:23:25 +05:30
end
it { is_expected.to eq(100) }
end
2022-08-13 15:12:31 +05:30
2022-10-11 01:57:18 +05:30
context 'with security_actions_continuous_onboarding experiment' do
2022-08-13 15:12:31 +05:30
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
2021-06-08 01:23:25 +05:30
end
end