blob: dd7648f77991776183a18d874aa97ff8b79cc4d4 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Onboarding::Completion, feature_category: :onboarding do
let(:completed_actions) { {} }
let(:project) { build(:project, namespace: namespace) }
let!(:onboarding_progress) { create(:onboarding_progress, namespace: namespace, **completed_actions) }
let_it_be(:namespace) { create(:namespace) }
describe '#percentage' do
let(:tracked_action_columns) do
[*described_class::ACTION_PATHS, :security_scan_enabled].map do |key|
::Onboarding::Progress.column_name(key)
end
end
subject(:percentage) { described_class.new(project).percentage }
context 'when no onboarding_progress exists' do
subject(:percentage) { described_class.new(build(:project)).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(:project) { build(:project, :stubbed_commit_count, namespace: namespace) }
let(:completed_actions) do
tracked_action_columns.index_with { Time.current }
end
it { is_expected.to eq(100) }
end
end
describe '#completed?' do
subject(:completed?) { described_class.new(project).completed?(column) }
context 'when code_added' do
let(:column) { :code_added }
context 'when commit_count > 1' do
let(:project) { build(:project, :stubbed_commit_count, namespace: namespace) }
it { is_expected.to eq(true) }
end
context 'when branch_count > 1' do
let(:project) { build(:project, :stubbed_branch_count, namespace: namespace) }
it { is_expected.to eq(true) }
end
context 'when empty repository' do
let(:project) { build(:project, namespace: namespace) }
it { is_expected.to eq(false) }
end
end
context 'when secure_dast_run' do
let(:column) { :secure_dast_run_at }
let(:completed_actions) { { secure_dast_run_at: secure_dast_run_at } }
context 'when is completed' do
let(:secure_dast_run_at) { Time.current }
it { is_expected.to eq(true) }
end
context 'when is not completed' do
let(:secure_dast_run_at) { nil }
it { is_expected.to eq(false) }
end
end
end
end
|