Commit 094128a5 authored by Kerri Miller's avatar Kerri Miller

Replace delegated predicate methods with boolean-returning methods

parent 798dd96d
......@@ -200,7 +200,6 @@ module EE
delegate :auto_rollback_enabled, :auto_rollback_enabled=, :auto_rollback_enabled?, to: :ci_cd_settings
delegate :closest_gitlab_subscription, to: :namespace
delegate :jira_vulnerabilities_integration_enabled?, :configured_to_create_issues_from_vulnerabilities?, to: :jira_service, allow_nil: true
delegate :requirements_access_level, :security_and_compliance_access_level, to: :project_feature, allow_nil: true
delegate :pipeline_configuration_full_path, to: :compliance_management_framework, allow_nil: true
......@@ -239,6 +238,18 @@ module EE
::Feature.enabled?(:jira_issue_association_on_merge_request, self) &&
feature_available?(:jira_issue_association_enforcement)
end
def jira_vulnerabilities_integration_enabled?
return false unless jira_service
jira_service.jira_vulnerabilities_integration_enabled?
end
def configured_to_create_issues_from_vulnerabilities?
return false unless jira_service
jira_service.configured_to_create_issues_from_vulnerabilities?
end
end
class_methods do
......
......@@ -59,6 +59,48 @@ RSpec.describe Project do
it { is_expected.to have_many(:incident_management_oncall_schedules).class_name('IncidentManagement::OncallSchedule') }
it { is_expected.to have_many(:incident_management_oncall_rotations).through(:incident_management_oncall_schedules).source(:rotations) }
describe '#jira_vulnerabilities_integration_enabled?' do
context 'when project lacks a jira_service relation' do
it 'returns false' do
expect(project.jira_vulnerabilities_integration_enabled?).to be_falsey
end
end
context 'when project has a jira_service relation' do
before do
create(:jira_service, project: project)
end
it 'accesses the value from the jira_service' do
expect(project.jira_service)
.to receive(:jira_vulnerabilities_integration_enabled?)
project.jira_vulnerabilities_integration_enabled?
end
end
end
describe '#configured_to_create_issues_from_vulnerabilities?' do
context 'when project lacks a jira_service relation' do
it 'returns false' do
expect(project.configured_to_create_issues_from_vulnerabilities?).to be_falsey
end
end
context 'when project has a jira_service relation' do
before do
create(:jira_service, project: project)
end
it 'accesses the value from the jira_service' do
expect(project.jira_service)
.to receive(:configured_to_create_issues_from_vulnerabilities?)
project.configured_to_create_issues_from_vulnerabilities?
end
end
end
describe '#jira_issue_association_required_to_merge_enabled?' do
using RSpec::Parameterized::TableSyntax
......
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