Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
dd08202a
Commit
dd08202a
authored
Jun 21, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix builds API response not including commit data
parent
0d287b06
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
13 deletions
+44
-13
app/models/commit_status.rb
app/models/commit_status.rb
+8
-0
lib/api/entities.rb
lib/api/entities.rb
+1
-5
spec/models/build_spec.rb
spec/models/build_spec.rb
+12
-1
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+15
-4
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+8
-3
No files found.
app/models/commit_status.rb
View file @
dd08202a
...
...
@@ -90,4 +90,12 @@ class CommitStatus < ActiveRecord::Base
def
stuck?
false
end
##
# Deprecated, this should be removed in 9.0 in favor of exposing
# entire pipeline in API.
#
def
commit
pipeline
.
try
(
:commit_data
)
end
end
lib/api/entities.rb
View file @
dd08202a
...
...
@@ -445,11 +445,7 @@ module API
expose
:created_at
,
:started_at
,
:finished_at
expose
:user
,
with:
User
expose
:artifacts_file
,
using:
BuildArtifactFile
,
if:
->
(
build
,
opts
)
{
build
.
artifacts?
}
expose
:commit
,
with:
RepoCommit
do
|
repo_obj
,
_options
|
if
repo_obj
.
respond_to?
(
:commit
)
repo_obj
.
commit
.
commit_data
end
end
expose
:commit
,
with:
RepoCommit
expose
:runner
,
with:
Runner
end
...
...
spec/models/build_spec.rb
View file @
dd08202a
...
...
@@ -2,7 +2,12 @@ require 'spec_helper'
describe
Ci
::
Build
,
models:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
)
end
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
{
is_expected
.
to
validate_presence_of
:ref
}
...
...
@@ -658,4 +663,10 @@ describe Ci::Build, models: true do
end
end
end
describe
'#commit'
do
it
'returns commit pipeline has been created for'
do
expect
(
build
.
commit
).
to
eq
project
.
commit
end
end
end
spec/models/commit_status_spec.rb
View file @
dd08202a
require
'spec_helper'
describe
CommitStatus
,
models:
true
do
let
(
:pipeline
)
{
FactoryGirl
.
create
:ci_pipeline
}
let
(
:commit_status
)
{
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
)
end
let
(
:commit_status
)
{
create
(
:commit_status
,
pipeline:
pipeline
)
}
it
{
is_expected
.
to
belong_to
(
:pipeline
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
...
...
@@ -198,4 +203,10 @@ describe CommitStatus, models: true do
end
end
end
describe
'#commit'
do
it
'returns commit pipeline has been created for'
do
expect
(
commit_status
.
commit
).
to
eq
project
.
commit
end
end
end
spec/requests/api/builds_spec.rb
View file @
dd08202a
...
...
@@ -9,8 +9,8 @@ describe API::API, api: true do
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:developer
)
{
create
(
:project_member
,
:developer
,
user:
user
,
project:
project
)
}
let!
(
:reporter
)
{
create
(
:project_member
,
:reporter
,
user:
user2
,
project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
)
}
let
!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
describe
'GET /projects/:id/builds '
do
let
(
:query
)
{
''
}
...
...
@@ -23,6 +23,11 @@ describe API::API, api: true do
expect
(
json_response
).
to
be_an
Array
end
it
'returns correct values'
do
expect
(
json_response
).
not_to
be_empty
expect
(
json_response
.
first
[
'commit'
][
'id'
]).
to
eq
project
.
commit
.
id
end
context
'filter project with one scope element'
do
let
(
:query
)
{
'scope=pending'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment