blob: 83e57b852a0fdce047250ed544505e02fe29a990 (
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
|
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe ResetSeverityLevelsToNewDefault, feature_category: :source_code_management do
let(:approval_project_rules) { table(:approval_project_rules) }
let(:projects) { table(:projects) }
let(:namespaces) { table(:namespaces) }
let(:namespace) { namespaces.create!(name: 'namespace', path: 'namespace') }
let(:project) { projects.create!(name: 'project', path: 'project', namespace_id: namespace.id) }
let(:approval_project_rule) { approval_project_rules.create!(name: 'rule', project_id: project.id, severity_levels: severity_levels) }
context 'without having all severity levels selected' do
let(:severity_levels) { ['high'] }
it 'does not change severity_levels' do
expect(approval_project_rule.severity_levels).to eq(severity_levels)
expect { migrate! }.not_to change { approval_project_rule.reload.severity_levels }
end
end
context 'with all scanners selected' do
let(:severity_levels) { ::Enums::Vulnerability::SEVERITY_LEVELS.keys }
let(:default_levels) { %w(unknown high critical) }
it 'changes severity_levels to the default value' do
expect(approval_project_rule.severity_levels).to eq(severity_levels)
expect { migrate! }.to change { approval_project_rule.reload.severity_levels }.from(severity_levels).to(default_levels)
end
end
end
|