gitlab-org--gitlab-foss/app/serializers/build_entity.rb
Filipa Lacerda 1b85c5a73f Merge branch 'master' into tc-fix-unplayable-build-action-404
* master: (525 commits)
  Introduce "polling_interval_multiplier" as application setting
  fix spelling CI_REPOSITORY_URL (line:355) gitab-ci-token to gitlab-ci-token.
  Pass Gitaly Repository messages to workhorse
  Use gitaly 0.5.0
  Fix specs
  Improve specs examples
  Minor refactor
  Fix BrachFormatter for removed users
  Changelog
  Fix specs
  One more change to the branch names to preserve metadata
  Prefixes source branch name with short SHA to avoid collision
  Fix GitHub importer for PRs of deleted forked repositories
  Change order of specs
  Clean history after every test that changes history
  Clean history state after each test
  Fixes method not replacing URL parameters correctly
  Fix a transient failure caused by FFaker
  Remove unnecessary ORDER BY clause when updating todos
  Add a wait_for_ajax call to ensure Todos page cleans up properly
  ...
2017-04-03 17:22:18 +01:00

35 lines
753 B
Ruby

class BuildEntity < Grape::Entity
include RequestAwareEntity
expose :id
expose :name
expose :build_path do |build|
path_to(:namespace_project_build, build)
end
expose :retry_path do |build|
path_to(:retry_namespace_project_build, build)
end
expose :play_path, if: ->(build, _) { build.playable? } do |build|
path_to(:play_namespace_project_build, build)
end
expose :playable?, as: :playable
expose :created_at
expose :updated_at
expose :detailed_status, as: :status, with: StatusEntity
private
alias_method :build, :object
def path_to(route, build)
send("#{route}_path", build.project.namespace, build.project, build)
end
def detailed_status
build.detailed_status(request.user)
end
end