diff options
author | Steve Azzopardi <steveazz@outlook.com> | 2018-09-05 19:11:13 +0200 |
---|---|---|
committer | Steve Azzopardi <steveazz@outlook.com> | 2018-09-06 13:35:56 +0200 |
commit | 26f577df8023c1efa1ae776bb976f38ab0de4a3f (patch) | |
tree | 7bef3896001156a5be039b6dcd4c5459687c0ca9 /app/serializers/build_details_entity.rb | |
parent | c6d315b4bb06be644c1c8ca47268bed71c679dd6 (diff) | |
download | gitlab-ce-26f577df8023c1efa1ae776bb976f38ab0de4a3f.tar.gz |
Add terminal path to job API response
closes #51117
Diffstat (limited to 'app/serializers/build_details_entity.rb')
-rw-r--r-- | app/serializers/build_details_entity.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb index 271ff668eda..b107fc26f18 100644 --- a/app/serializers/build_details_entity.rb +++ b/app/serializers/build_details_entity.rb @@ -36,6 +36,10 @@ class BuildDetailsEntity < JobEntity erase_project_job_path(project, build) end + expose :terminal_path, if: -> (*) { can_create_build_terminal? } do |build| + terminal_project_job_path(project, build) + end + expose :merge_request, if: -> (*) { can?(current_user, :read_merge_request, build.merge_request) } do expose :iid do |build| build.merge_request.iid @@ -69,4 +73,8 @@ class BuildDetailsEntity < JobEntity def project build.project end + + def can_create_build_terminal? + can?(current_user, :create_build_terminal, build) && build.has_terminal? + end end |