Commit aaa0a6c5 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'mo-add-accessibility-report-merge-request' into 'master'

Add has_accessibility_reports to MergeRequest

See merge request gitlab-org/gitlab!31023
parents 0b5598be 5793caac
...@@ -1300,6 +1300,12 @@ class MergeRequest < ApplicationRecord ...@@ -1300,6 +1300,12 @@ class MergeRequest < ApplicationRecord
compare_reports(Ci::CompareTestReportsService) compare_reports(Ci::CompareTestReportsService)
end end
def has_accessibility_reports?
return false unless Feature.enabled?(:accessibility_report_view, project)
actual_head_pipeline.present? && actual_head_pipeline.has_reports?(Ci::JobArtifact.accessibility_reports)
end
def has_coverage_reports? def has_coverage_reports?
return false unless Feature.enabled?(:coverage_report_view, project) return false unless Feature.enabled?(:coverage_report_view, project)
......
...@@ -121,6 +121,18 @@ FactoryBot.define do ...@@ -121,6 +121,18 @@ FactoryBot.define do
end end
end end
trait :with_accessibility_reports do
after(:build) do |merge_request|
merge_request.head_pipeline = build(
:ci_pipeline,
:success,
:with_accessibility_reports,
project: merge_request.source_project,
ref: merge_request.source_branch,
sha: merge_request.diff_head_sha)
end
end
trait :with_coverage_reports do trait :with_coverage_reports do
after(:build) do |merge_request| after(:build) do |merge_request|
merge_request.head_pipeline = build( merge_request.head_pipeline = build(
......
...@@ -1612,6 +1612,32 @@ describe MergeRequest do ...@@ -1612,6 +1612,32 @@ describe MergeRequest do
end end
end end
describe '#has_accessibility_reports?' do
subject { merge_request.has_accessibility_reports? }
let(:project) { create(:project, :repository) }
context 'when head pipeline has an accessibility reports' do
let(:merge_request) { create(:merge_request, :with_accessibility_reports, source_project: project) }
it { is_expected.to be_truthy }
context 'when feature flag is disabled' do
before do
stub_feature_flags(accessibility_report_view: false)
end
it { is_expected.to be_falsey }
end
end
context 'when head pipeline does not have accessibility reports' do
let(:merge_request) { create(:merge_request, source_project: project) }
it { is_expected.to be_falsey }
end
end
describe '#has_coverage_reports?' do describe '#has_coverage_reports?' do
subject { merge_request.has_coverage_reports? } subject { merge_request.has_coverage_reports? }
......
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