Commit 592cabc6 authored by Mark Chao's avatar Mark Chao

Merge branch '327955-fix-dependency-list-refresh' into 'master'

Ensure dependency list shows successful pipelines

See merge request gitlab-org/gitlab!65637
parents c9870bb4 c66b8747
......@@ -323,7 +323,7 @@ module EE
end
def latest_pipeline_with_reports(reports)
all_pipelines.newest_first(ref: default_branch).with_reports(reports).take
all_pipelines.success.newest_first(ref: default_branch).with_reports(reports).take
end
def security_reports_up_to_date_for_ref?(ref)
......
......@@ -70,7 +70,7 @@ RSpec.describe Projects::LicensesController do
end
context 'with existing report' do
let!(:pipeline) { create(:ci_pipeline, project: project, builds: [create(:ee_ci_build, :success, :license_scan_v2_1)]) }
let!(:pipeline) { create(:ci_pipeline, project: project, builds: [create(:ee_ci_build, :success, :license_scan_v2_1)], status: :success) }
before do
get_licenses
......@@ -127,7 +127,7 @@ RSpec.describe Projects::LicensesController do
let_it_be(:mit_policy) { create(:software_license_policy, :denied, software_license: mit, project: project) }
let_it_be(:other_license) { create(:software_license, spdx_identifier: "Other-Id") }
let_it_be(:other_license_policy) { create(:software_license_policy, :allowed, software_license: other_license, project: project) }
let_it_be(:pipeline) { create(:ee_ci_pipeline, project: project, builds: [create(:ee_ci_build, :license_scan_v2_1, :success)]) }
let_it_be(:pipeline) { create(:ee_ci_pipeline, project: project, builds: [create(:ee_ci_build, :license_scan_v2_1, :success)], status: :success) }
context "when loading all policies" do
before do
......
......@@ -28,7 +28,7 @@ RSpec.describe 'EE > Projects > Licenses > Maintainer views policies', :js do
context "when a policy is configured" do
let_it_be(:mit) { create(:software_license, :mit) }
let_it_be(:mit_policy) { create(:software_license_policy, :denied, software_license: mit, project: project) }
let_it_be(:pipeline) { create(:ee_ci_pipeline, project: project, builds: [create(:ee_ci_build, :license_scan_v2, :success)]) }
let_it_be(:pipeline) { create(:ee_ci_pipeline, project: project, builds: [create(:ee_ci_build, :license_scan_v2, :success)], status: :success) }
let(:report) { Gitlab::Json.parse(fixture_file('security_reports/gl-license-scanning-report-v2.json', dir: 'ee')) }
let(:known_licenses) { report['licenses'].find_all { |license| license['url'].present? } }
......
......@@ -1791,19 +1791,27 @@ RSpec.describe Project do
end
describe '#latest_pipeline_with_reports' do
let(:project) { create(:project) }
let!(:pipeline_1) { create(:ee_ci_pipeline, :with_sast_report, project: project) }
let!(:pipeline_2) { create(:ee_ci_pipeline, :with_sast_report, project: project) }
let!(:pipeline_3) { create(:ee_ci_pipeline, :with_dependency_scanning_report, project: project) }
let_it_be(:project) { create(:project) }
let_it_be(:pipeline_1) { create(:ee_ci_pipeline, :with_sast_report, project: project) }
let_it_be(:pipeline_2) { create(:ee_ci_pipeline, :with_sast_report, project: project) }
let_it_be(:pipeline_3) { create(:ee_ci_pipeline, :with_dependency_scanning_report, project: project) }
subject { project.latest_pipeline_with_reports(reports) }
context 'when reports are found' do
let(:reports) { ::Ci::JobArtifact.sast_reports }
let_it_be(:reports) { ::Ci::JobArtifact.sast_reports }
it "returns the latest pipeline with reports of right type" do
is_expected.to eq(pipeline_2)
end
context 'and one of the pipelines has not yet completed' do
let_it_be(:pipeline_4) { create(:ee_ci_pipeline, :with_sast_report, project: project, status: :running) }
it 'returns the latest successful pipeline with reports' do
is_expected.to eq(pipeline_2)
end
end
end
context 'when reports are not found' do
......
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