Commit e59cd3af authored by Michael Kozono's avatar Michael Kozono

Merge branch 'fix_specs_n+1' into 'master'

Fix specs for store_report_service_spec

See merge request gitlab-org/gitlab!59536
parents 3fbe31c1 352fb142
......@@ -15,10 +15,17 @@ RSpec.describe Security::StoreReportService, '#execute' do
subject { described_class.new(pipeline, report).execute }
where(vulnerability_finding_signatures_enabled: [true, false])
where(:vulnerability_finding_signatures_enabled, :optimize_sql_query_for_security_report_ff) do
true | true
true | false
false | true
false | false
end
with_them do
before do
stub_feature_flags(vulnerability_finding_signatures: vulnerability_finding_signatures_enabled)
stub_feature_flags(optimize_sql_query_for_security_report: optimize_sql_query_for_security_report_ff)
stub_licensed_features(sast: true, dependency_scanning: true, container_scanning: true, security_dashboard: true)
allow(Security::AutoFixWorker).to receive(:perform_async)
end
......@@ -35,18 +42,14 @@ RSpec.describe Security::StoreReportService, '#execute' do
end
context 'for different security reports' do
with_them do
before do
stub_feature_flags(optimize_sql_query_for_security_report: optimize_sql_query_for_security_report_ff)
end
where(:case_name, :trait, :scanners, :identifiers, :findings, :finding_identifiers, :finding_pipelines, :remediations, :signatures) do
'with SAST report' | :sast | 1 | 6 | 5 | 7 | 5 | 0 | 2
'with exceeding identifiers' | :with_exceeding_identifiers | 1 | 20 | 1 | 20 | 1 | 0 | 1
'with Dependency Scanning report' | :dependency_scanning_remediation | 1 | 3 | 2 | 3 | 2 | 1 | 2
'with Container Scanning report' | :container_scanning | 1 | 8 | 8 | 8 | 8 | 0 | 8
end
where(:case_name, :trait, :scanners, :identifiers, :findings, :finding_identifiers, :finding_pipelines, :remediations, :signatures) do
'with SAST report' | :sast | 1 | 6 | 5 | 7 | 5 | 0 | 2
'with exceeding identifiers' | :with_exceeding_identifiers | 1 | 20 | 1 | 20 | 1 | 0 | 0
'with Dependency Scanning report' | :dependency_scanning_remediation | 1 | 3 | 2 | 3 | 2 | 1 | 0
'with Container Scanning report' | :container_scanning | 1 | 8 | 8 | 8 | 8 | 0 | 0
end
with_them do
it 'inserts all scanners' do
expect { subject }.to change { Vulnerabilities::Scanner.count }.by(scanners)
end
......@@ -76,7 +79,8 @@ RSpec.describe Security::StoreReportService, '#execute' do
end
it 'inserts all signatures' do
expect { subject }.to change { Vulnerabilities::FindingSignature.count }.by(signatures)
signatures_count = vulnerability_finding_signatures_enabled ? signatures : 0
expect { subject }.to change { Vulnerabilities::FindingSignature.count }.by(signatures_count)
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