Commit faac2f85 authored by Stan Hu's avatar Stan Hu

Merge branch '292798-rework-project-security-settings-tests' into 'master'

Rework ProjectSecuritySetting with test table

See merge request gitlab-org/gitlab!50447
parents e495f2d8 1b52f3b6
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ProjectSecuritySetting do RSpec.describe ProjectSecuritySetting do
using RSpec::Parameterized::TableSyntax
describe 'associations' do describe 'associations' do
subject { create(:project).security_setting } subject { create(:project).security_setting }
...@@ -12,55 +14,29 @@ RSpec.describe ProjectSecuritySetting do ...@@ -12,55 +14,29 @@ RSpec.describe ProjectSecuritySetting do
describe '#auto_fix_enabled?' do describe '#auto_fix_enabled?' do
subject { setting.auto_fix_enabled? } subject { setting.auto_fix_enabled? }
let_it_be(:setting) { build(:project_security_setting) } let(:setting) { build(:project_security_setting) }
context 'when licensed feature is enabled' do
before do
stub_licensed_features(vulnerability_auto_fix: true)
end
context 'when auto fix is enabled for available feature' do
before do
setting.auto_fix_container_scanning = false
setting.auto_fix_dependency_scanning = true
end
it 'marks auto_fix as enabled' do
is_expected.to be_truthy
end
end
context 'when a auto_fix setting is disabled for available features' do where(:license, :feature_flag, :auto_fix_container_scanning, :auto_fix_dependency_scanning, :auto_fix_sast, :auto_fix_enabled?) do
before do true | true | true | true | true | true
setting.auto_fix_container_scanning = false false | true | true | true | true | false
setting.auto_fix_dependency_scanning = false true | false | true | true | true | false
setting.auto_fix_sast = false true | true | false | true | true | true
end true | true | true | false | true | true
true | true | false | false | true | false
it 'marks auto_fix as disabled' do true | true | true | true | false | true
is_expected.to be_falsey
end
end
context 'when feature is disabled' do
before do
stub_feature_flags(security_auto_fix: false)
end
it 'marks auto_fix as disabled' do
is_expected.to be_falsey
end
end
end end
context 'when license feature is disabled' do with_them do
before do before do
stub_licensed_features(vulnerability_auto_fix: false) stub_licensed_features(vulnerability_auto_fix: license)
end stub_feature_flags(security_auto_fix: feature_flag)
it 'marks auto_fix as disabled' do setting.auto_fix_container_scanning = auto_fix_container_scanning
is_expected.to be_falsey setting.auto_fix_dependency_scanning = auto_fix_dependency_scanning
setting.auto_fix_sast = auto_fix_sast
end end
it { is_expected.to eq(auto_fix_enabled?) }
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment