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