Commit 0a8fe94b authored by Alessio Caiazza's avatar Alessio Caiazza

Merge branch 'tancnle/memoize-project-regulated-settings-check' into 'master'

Memoize project regulated settings check

See merge request gitlab-org/gitlab!37403
parents 3e0b9c0f b011e9ad
......@@ -216,11 +216,13 @@ module EE
end
def has_regulated_settings?
return unless compliance_framework_setting
strong_memoize(:has_regulated_settings) do
next false unless compliance_framework_setting
compliance_framework_id = ::ComplianceManagement::ComplianceFramework::FRAMEWORKS[compliance_framework_setting.framework.to_sym]
::Gitlab::CurrentSettings.current_application_settings.compliance_frameworks.include?(compliance_framework_id)
end
end
def can_store_security_reports?
namespace.store_security_reports_available? || public?
......
---
title: Memoize project regulated settings check
merge_request: 37403
author:
type: performance
......@@ -573,9 +573,9 @@ RSpec.describe Project do
end
describe '#has_regulated_settings?' do
let_it_be(:framework) { ComplianceManagement::ComplianceFramework::FRAMEWORKS.first }
let_it_be(:compliance_framework_setting) { create(:compliance_framework_project_setting, framework: framework.first.to_s) }
let_it_be(:project) { create(:project, compliance_framework_setting: compliance_framework_setting) }
let(:framework) { ComplianceManagement::ComplianceFramework::FRAMEWORKS.first }
let(:compliance_framework_setting) { build(:compliance_framework_project_setting, framework: framework.first.to_s) }
let(:project) { build(:project, compliance_framework_setting: compliance_framework_setting) }
subject { project.has_regulated_settings? }
......@@ -596,7 +596,7 @@ RSpec.describe Project do
end
context 'project does not have compliance framework' do
let_it_be(:project) { create(:project) }
let(:project) { build(:project) }
it { is_expected.to be_falsey }
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