Commit 5793caac authored by Maxime Orefice's avatar Maxime Orefice Committed by Mayra Cabrera

Add has_accessibility_reports to MergeRequest

parent f2f74407
......@@ -1300,6 +1300,12 @@ class MergeRequest < ApplicationRecord
compare_reports(Ci::CompareTestReportsService)
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?
return false unless Feature.enabled?(:coverage_report_view, project)
......
......@@ -121,6 +121,18 @@ FactoryBot.define do
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
after(:build) do |merge_request|
merge_request.head_pipeline = build(
......
......@@ -1612,6 +1612,32 @@ describe MergeRequest do
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
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