Commit aef1c8d8 authored by Michał Zając's avatar Michał Zając

Use latest successful pipeline for default branch

parent c61de9d3
......@@ -74,8 +74,8 @@ class Vulnerability < ApplicationRecord
end
def resolved_on_default_branch
latest_pipeline_for_default_branch = project.pipeline_for(project_default_branch)
latest_successful_pipeline_for_default_branch = project.latest_successful_pipeline_for_default_branch
latest_pipeline_with_vulnerability = finding.pipelines.order(created_at: :desc).first
latest_pipeline_with_vulnerability != latest_pipeline_for_default_branch
latest_pipeline_with_vulnerability != latest_successful_pipeline_for_default_branch
end
end
......@@ -183,7 +183,7 @@ describe Vulnerability do
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) }
let_it_be(:pipeline_with_vulnerability) { create(:ci_pipeline, :success, project: project, sha: project.commit.id) }
let_it_be(:vulnerability) { project.vulnerabilities.first }
let_it_be(:finding1) { create(:vulnerabilities_occurrence, vulnerability: vulnerability, pipelines: [pipeline_with_vulnerability]) }
let_it_be(:finding2) { create(:vulnerabilities_occurrence, vulnerability: vulnerability, pipelines: [pipeline_with_vulnerability]) }
......@@ -195,7 +195,11 @@ describe Vulnerability do
end
context 'Vulnerability::Occurrence is not present on the pipeline for default branch' do
let_it_be(:pipeline_without_vulnerability) { create(:ci_pipeline, project: project, sha: project.commit.id) }
before do
project.instance_variable_set(:@latest_successful_pipeline_for_default_branch, pipeline_without_vulnerability)
end
let_it_be(:pipeline_without_vulnerability) { create(:ci_pipeline, :success, project: project, sha: project.commit.id) }
it { is_expected.to eq(true) }
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