Commit c3fd1491 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add blob_path to sast data

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent dfa600a6
......@@ -212,10 +212,16 @@ class MergeRequestEntity < IssuableEntity
end
end
expose :sast_path, if: -> (mr, _) { expose_sast_data?(mr, current_user) } do |merge_request|
raw_project_build_artifacts_url(merge_request.source_project,
merge_request.sast_artifact,
path: 'gl-sast-report.json')
expose :sast, if: -> (mr, _) { expose_sast_data?(mr, current_user) } do
expose :path do |merge_request|
raw_project_build_artifacts_url(merge_request.source_project,
merge_request.sast_artifact,
path: 'gl-sast-report.json')
end
expose :blob_path, if: -> (mr, _) { mr.head_pipeline_sha } do |merge_request|
project_blob_path(merge_request.project, merge_request.head_pipeline_sha)
end
end
private
......
......@@ -170,4 +170,14 @@ describe MergeRequest do
describe '#sast_artifact' do
it { is_expected.to delegate_method(:sast_artifact).to(:head_pipeline) }
end
describe '#has_sast_data?' do
let(:artifact) { double(success?: true) }
before do
allow(merge_request).to receive(:sast_artifact).and_return(artifact)
end
it { expect(merge_request.has_sast_data?).to be_truthy }
end
end
......@@ -15,6 +15,6 @@ describe MergeRequestEntity do
allow(subject).to receive(:expose_sast_data?).and_return(true)
allow(merge_request).to receive(:sast_artifact).and_return(build)
expect(subject.as_json).to include(:sast_path)
expect(subject.as_json).to include(:sast)
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