2017-06-07 09:36:41 +00:00
|
|
|
class BuildDetailsEntity < JobEntity
|
2017-05-23 15:10:07 +00:00
|
|
|
expose :coverage, :erased_at, :duration
|
|
|
|
expose :tag_list, as: :tags
|
2017-06-01 19:34:44 +00:00
|
|
|
expose :user, using: UserEntity
|
2017-06-13 09:05:48 +00:00
|
|
|
expose :runner, using: RunnerEntity
|
|
|
|
expose :pipeline, using: PipelineEntity
|
2017-06-01 19:34:44 +00:00
|
|
|
|
2017-05-29 07:58:20 +00:00
|
|
|
expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity
|
|
|
|
expose :erase_path, if: -> (*) { build.erasable? && can?(current_user, :update_build, project) } do |build|
|
2017-06-29 17:06:35 +00:00
|
|
|
erase_project_job_path(project, build)
|
2017-05-29 07:58:20 +00:00
|
|
|
end
|
|
|
|
|
2017-06-01 19:34:44 +00:00
|
|
|
expose :merge_request, if: -> (*) { can?(current_user, :read_merge_request, build.merge_request) } do
|
2017-05-29 07:58:20 +00:00
|
|
|
expose :iid do |build|
|
|
|
|
build.merge_request.iid
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :path do |build|
|
2017-06-29 17:06:35 +00:00
|
|
|
project_merge_request_path(project, build.merge_request)
|
2017-05-29 07:58:20 +00:00
|
|
|
end
|
2017-05-23 15:10:07 +00:00
|
|
|
end
|
|
|
|
|
2017-06-02 18:32:37 +00:00
|
|
|
expose :new_issue_path, if: -> (*) { can?(request.current_user, :create_issue, project) && build.failed? } do |build|
|
2017-06-29 17:06:35 +00:00
|
|
|
new_project_issue_path(project, issue: build_failed_issue_options)
|
2017-05-23 15:10:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :raw_path do |build|
|
2017-06-29 17:06:35 +00:00
|
|
|
raw_project_job_path(project, build)
|
2017-05-23 15:10:07 +00:00
|
|
|
end
|
2017-05-26 08:31:42 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-06-02 18:32:37 +00:00
|
|
|
def build_failed_issue_options
|
2017-06-12 09:20:19 +00:00
|
|
|
{ title: "Build Failed ##{build.id}",
|
2017-06-29 17:06:35 +00:00
|
|
|
description: project_job_path(project, build) }
|
2017-06-02 18:32:37 +00:00
|
|
|
end
|
|
|
|
|
2017-05-26 08:31:42 +00:00
|
|
|
def current_user
|
|
|
|
request.current_user
|
|
|
|
end
|
|
|
|
|
|
|
|
def project
|
|
|
|
build.project
|
|
|
|
end
|
2017-05-23 15:10:07 +00:00
|
|
|
end
|