Skip to content
代码片段 群组 项目
未验证 提交 6775a749 编辑于 作者: Michał Zając's avatar Michał Zając
浏览文件

Add #project_default_branch to Vulnerability

上级 4ab27275
No related branches found
No related tags found
无相关合并请求
......@@ -60,6 +60,8 @@ def with_vulnerability_links
scope :with_severities, -> (severities) { where(severity: severities) }
scope :with_states, -> (states) { where(state: states) }
delegate :default_branch, to: :project, prefix: :project
# There will only be one finding associated with a vulnerability for the foreseeable future
def finding
findings.first
......@@ -72,8 +74,7 @@ def self.parent_class
end
def resolved_on_default_branch
default_branch = project.default_branch
latest_pipeline_for_default_branch = project.pipeline_for(default_branch)
latest_pipeline_for_default_branch = project.pipeline_for(project_default_branch)
latest_pipeline_with_vulnerability = finding.pipelines.order(created_at: :desc).first
latest_pipeline_with_vulnerability != latest_pipeline_for_default_branch
end
......
......@@ -17,6 +17,7 @@ class Vulnerability < Grape::Entity
expose :finding
expose :resolved_on_default_branch
expose :project_default_branch
expose :author_id
expose :updated_by_id
......
......@@ -172,6 +172,15 @@
it { is_expected.to eq(finding.scanner_name) }
end
describe '#project_default_branch' do
let_it_be(:project) { create(:project, :repository, :with_vulnerabilities) }
let_it_be(:vulnerability) { project.vulnerabilities.first }
subject { vulnerability.project_default_branch }
it { is_expected.to eq("master") }
end
describe '#resolved_on_default_branch' do
let_it_be(:project) { create(:project, :repository, :with_vulnerabilities) }
let_it_be(:pipeline_with_vulnerability) { create(:ci_pipeline, project: project, sha: project.commit.id) }
......
......@@ -72,4 +72,4 @@ DEPENDENCIES
scss_lint (~> 0.56.0)
BUNDLED WITH
1.17.3
2.1.4
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册