mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-11 21:56:19 +10:00
Modify entities for builds API
This commit is contained in:
+11
-5
@@ -15,7 +15,9 @@ module API
|
||||
get ':id/builds' do
|
||||
builds = user_project.builds.order('id DESC')
|
||||
builds = filter_builds(builds, params[:scope])
|
||||
present paginate(builds), with: Entities::Build
|
||||
|
||||
present paginate(builds), with: Entities::Build,
|
||||
user_can_download_artifacts: can?(current_user, :download_build_artifacts, user_project)
|
||||
end
|
||||
|
||||
# Get builds for a specific commit of a project
|
||||
@@ -33,7 +35,8 @@ module API
|
||||
|
||||
builds = commit.builds.order('id DESC')
|
||||
builds = filter_builds(builds, params[:scope])
|
||||
present paginate(builds), with: Entities::Build
|
||||
present paginate(builds), with: Entities::Build,
|
||||
user_can_download_artifacts: can?(current_user, :download_build_artifacts, user_project)
|
||||
end
|
||||
|
||||
# Get a specific build of a project
|
||||
@@ -47,7 +50,8 @@ module API
|
||||
build = get_build(params[:build_id])
|
||||
return not_found!(build) unless build
|
||||
|
||||
present build, with: Entities::Build
|
||||
present build, with: Entities::Build,
|
||||
user_can_download_artifacts: can?(current_user, :download_build_artifacts, user_project)
|
||||
end
|
||||
|
||||
# Get a trace of a specific build of a project
|
||||
@@ -84,7 +88,8 @@ module API
|
||||
|
||||
build.cancel
|
||||
|
||||
present build, with: Entities::Build
|
||||
present build, with: Entities::Build,
|
||||
user_can_download_artifacts: can?(current_user, :download_build_artifacts, user_project)
|
||||
end
|
||||
|
||||
# Retry a specific build of a project
|
||||
@@ -102,7 +107,8 @@ module API
|
||||
|
||||
build = Ci::Build.retry(build)
|
||||
|
||||
present build, with: Entities::Build
|
||||
present build, with: Entities::Build,
|
||||
user_can_download_artifacts: can?(current_user, :download_build_artifacts, user_project)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+18
-19
@@ -366,16 +366,8 @@ module API
|
||||
expose :id, :variables
|
||||
end
|
||||
|
||||
class CiCommit < Grape::Entity
|
||||
class Runner < Grape::Entity
|
||||
expose :id
|
||||
expose :ref
|
||||
expose :sha
|
||||
expose :committed_at
|
||||
end
|
||||
|
||||
class CiRunner < Grape::Entity
|
||||
expose :id
|
||||
expose :token
|
||||
expose :description
|
||||
expose :active
|
||||
expose :is_shared
|
||||
@@ -383,16 +375,23 @@ module API
|
||||
end
|
||||
|
||||
class Build < Grape::Entity
|
||||
expose :id
|
||||
expose :status
|
||||
expose :stage
|
||||
expose :name
|
||||
expose :ref
|
||||
expose :commit, with: CiCommit
|
||||
expose :runner, with: CiRunner
|
||||
expose :created_at
|
||||
expose :started_at
|
||||
expose :finished_at
|
||||
expose :id, :status, :stage, :name, :ref, :tag, :coverage, :user
|
||||
expose :created_at, :started_at, :finished_at
|
||||
expose :download_url do |repo_obj, options|
|
||||
if options[:user_can_download_artifacts]
|
||||
repo_obj.download_url
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
expose :commit, with: RepoCommit do |repo_obj, _options|
|
||||
if repo_obj.respond_to?(:commit)
|
||||
repo_obj.commit.commit_data
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
expose :runner, with: Runner
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,7 +74,6 @@ describe API::API, api: true do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(json_response['name']).to eq('test')
|
||||
expect(json_response['commit']['sha']).to eq(commit.sha)
|
||||
end
|
||||
|
||||
it 'should return specific build trace' do
|
||||
|
||||
Reference in New Issue
Block a user