diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-02 19:41:27 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-02 19:41:27 +0300 |
commit | eeb7245f5432ee126a86c186187ae78fd33ec1c4 (patch) | |
tree | fa80ebb8726ee7ab90752197a1b706d7ad7aeb1a /app/serializers | |
parent | 5115062dfa7191dcc35173e151f022217a107f70 (diff) | |
parent | 4fc52e1c81f95961d7c590d24bf78cbd04f138c0 (diff) |
Merge branch 'dz-codeclimate-compare-ee' into 'master'
Compare codeclimate artifacts on the merge request page
See merge request !1984
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/merge_request_entity.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/serializers/merge_request_entity.rb b/app/serializers/merge_request_entity.rb index 3a996ae8b77..c19b4486bc8 100644 --- a/app/serializers/merge_request_entity.rb +++ b/app/serializers/merge_request_entity.rb @@ -197,6 +197,23 @@ class MergeRequestEntity < IssuableEntity merge_request) end + # EE-specific + expose :codeclimate, if: -> (mr, _) { mr.has_codeclimate_data? } do + expose :head_path, if: -> (mr, _) { can?(current_user, :read_build, mr.head_codeclimate_artifact) } do |merge_request| + raw_namespace_project_build_artifacts_url(merge_request.source_project.namespace, + merge_request.source_project, + merge_request.head_codeclimate_artifact, + path: 'codeclimate.json') + end + + expose :base_path, if: -> (mr, _) { can?(current_user, :read_build, mr.base_codeclimate_artifact) } do |merge_request| + raw_namespace_project_build_artifacts_url(merge_request.target_project.namespace, + merge_request.target_project, + merge_request.base_codeclimate_artifact, + path: 'codeclimate.json') + end + end + private delegate :current_user, to: :request |