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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
6afff7c6
Commit
6afff7c6
authored
Jun 27, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix head pipeline stored in merge request for external pipelines
parent
99bdfd18
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
6 deletions
+28
-6
changelogs/unreleased/fix-head-pipeline-for-external-pipelines.md
...gs/unreleased/fix-head-pipeline-for-external-pipelines.md
+4
-0
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+3
-0
spec/requests/api/commit_statuses_spec.rb
spec/requests/api/commit_statuses_spec.rb
+21
-6
No files found.
changelogs/unreleased/fix-head-pipeline-for-external-pipelines.md
0 → 100644
View file @
6afff7c6
---
title: Fix head pipeline stored in merge request for external pipelines
merge_request:
author:
lib/api/commit_statuses.rb
View file @
6afff7c6
...
...
@@ -108,6 +108,9 @@ module API
render_api_error!
(
'invalid state'
,
400
)
end
MergeRequest
.
where
(
source_project:
@project
,
source_branch:
ref
)
.
update_all
(
head_pipeline_id:
pipeline
)
if
pipeline
.
latest?
present
status
,
with:
Entities
::
CommitStatus
rescue
StateMachines
::
InvalidTransition
=>
e
render_api_error!
(
e
.
message
,
400
)
...
...
spec/requests/api/commit_statuses_spec.rb
View file @
6afff7c6
...
...
@@ -164,25 +164,40 @@ describe API::CommitStatuses do
context
'with all optional parameters'
do
context
'when creating a commit status'
do
it
'creates commit status'
do
subject
do
post
api
(
post_url
,
developer
),
{
state:
'success'
,
context:
'coverage'
,
ref:
'
develop
'
,
ref:
'
master
'
,
description:
'test'
,
coverage:
80.0
,
target_url:
'http://gitlab.com/status'
}
end
it
'creates commit status'
do
subject
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'coverage'
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'
develop
'
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'
master
'
)
expect
(
json_response
[
'coverage'
]).
to
eq
(
80.0
)
expect
(
json_response
[
'description'
]).
to
eq
(
'test'
)
expect
(
json_response
[
'target_url'
]).
to
eq
(
'http://gitlab.com/status'
)
end
context
'when merge request exists for given branch'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
'master'
,
target_branch:
'develop'
)
}
it
'sets head pipeline'
do
subject
expect
(
response
).
to
have_http_status
(
201
)
expect
(
merge_request
.
reload
.
head_pipeline
).
not_to
be_nil
end
end
end
context
'when updatig a commit status'
do
...
...
@@ -190,7 +205,7 @@ describe API::CommitStatuses do
post
api
(
post_url
,
developer
),
{
state:
'running'
,
context:
'coverage'
,
ref:
'
develop
'
,
ref:
'
master
'
,
description:
'coverage test'
,
coverage:
0.0
,
target_url:
'http://gitlab.com/status'
...
...
@@ -199,7 +214,7 @@ describe API::CommitStatuses do
post
api
(
post_url
,
developer
),
{
state:
'success'
,
name:
'coverage'
,
ref:
'
develop
'
,
ref:
'
master
'
,
description:
'new description'
,
coverage:
90.0
}
...
...
@@ -210,7 +225,7 @@ describe API::CommitStatuses do
expect
(
json_response
[
'sha'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'status'
]).
to
eq
(
'success'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'coverage'
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'
develop
'
)
expect
(
json_response
[
'ref'
]).
to
eq
(
'
master
'
)
expect
(
json_response
[
'coverage'
]).
to
eq
(
90.0
)
expect
(
json_response
[
'description'
]).
to
eq
(
'new description'
)
expect
(
json_response
[
'target_url'
]).
to
eq
(
'http://gitlab.com/status'
)
...
...
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