Commit 7cf249de authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix sast_artifact method delegation and add some tests

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 59ff00cb
......@@ -202,7 +202,7 @@ class MergeRequestEntity < IssuableEntity
end
end
expose :sast_path, if: expose_sast_data(mr, current_user) do |merge_request|
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')
......
......@@ -11,7 +11,7 @@ module EE
delegate :codeclimate_artifact, to: :head_pipeline, prefix: :head, allow_nil: true
delegate :codeclimate_artifact, to: :base_pipeline, prefix: :base, allow_nil: true
delegate :sast_artifact, to: :head_pipeline, prefix: :false, allow_nil: true
delegate :sast_artifact, to: :head_pipeline, allow_nil: true
end
def rebase_dir_path
......
......@@ -166,4 +166,8 @@ describe MergeRequest do
it { is_expected.to eq(expected) }
end
end
describe '#sast_artifact' do
it { is_expected.to delegate_method(:sast_artifact).to(:head_pipeline) }
end
end
require 'spec_helper'
describe MergeRequestEntity do
let(:user) { create(:user) }
let(:project) { create :project, :repository }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:build) { create(:ci_build, name: 'sast') }
let(:request) { double('request', current_user: user) }
subject do
described_class.new(merge_request, request: request)
end
it 'has sast data' 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)
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