Commit e8eeee34 authored by drew cimino's avatar drew cimino

Expose merge_base_path on MR WidgetEntity

parent d7b3f6e8
......@@ -122,6 +122,10 @@ class MergeRequestWidgetEntity < Grape::Entity
expose :base_path do |merge_request|
base_pipeline_downloadable_path_for_report_type(:codequality)
end
expose :merge_base_path do |merge_request|
merge_target_pipeline_downloadable_path_for_report_type(:codequality)
end
end
expose :security_reports_docs_path do |merge_request|
......@@ -156,6 +160,11 @@ class MergeRequestWidgetEntity < Grape::Entity
object.base_pipeline&.present(current_user: current_user)
&.downloadable_path_for_report_type(file_type)
end
def merge_target_pipeline_downloadable_path_for_report_type(file_type)
object.merge_base_pipeline&.present(current_user: current_user)
&.downloadable_path_for_report_type(file_type)
end
end
MergeRequestWidgetEntity.prepend_if_ee('EE::MergeRequestWidgetEntity')
......@@ -92,21 +92,24 @@ RSpec.describe MergeRequestWidgetEntity do
project.add_developer(user)
allow(resource).to receive_messages(
merge_base_pipeline: pipeline,
base_pipeline: pipeline,
head_pipeline: pipeline
)
end
context "with report artifacts" do
context 'with report artifacts' do
let(:pipeline) { create(:ci_pipeline, :with_codequality_report, project: project) }
it "has data entry" do
expect(subject).to include(:codeclimate)
it 'has entries for 3 reference artifacts' do
expect(subject[:codeclimate][:merge_base_path]).to be_present
expect(subject[:codeclimate][:base_path]).to be_present
expect(subject[:codeclimate][:head_path]).to be_present
end
end
context "without artifacts" do
it "does not have data entry" do
context 'without artifacts' do
it 'does not have data entry' do
expect(subject).not_to include(:codeclimate)
end
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