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
5241a140
Commit
5241a140
authored
May 07, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
dcd4c4d1
552e9f74
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
19 deletions
+28
-19
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-7
changelogs/unreleased/fix-schedule-head-pipeline-update-method.yml
...s/unreleased/fix-schedule-head-pipeline-update-method.yml
+5
-0
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+22
-12
No files found.
app/services/ci/create_pipeline_service.rb
View file @
5241a140
...
...
@@ -104,17 +104,11 @@ module Ci
end
def
schedule_head_pipeline_update
related_merge_requests
.
each
do
|
merge_request
|
pipeline
.
all_merge_requests
.
opened
.
each
do
|
merge_request
|
UpdateHeadPipelineForMergeRequestWorker
.
perform_async
(
merge_request
.
id
)
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
related_merge_requests
pipeline
.
project
.
source_of_merge_requests
.
opened
.
where
(
source_branch:
pipeline
.
ref
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
extra_options
(
options
=
{})
# In Ruby 2.4, even when options is empty, f(**options) doesn't work when f
# doesn't have any parameters. We reproduce the Ruby 2.5 behavior by
...
...
changelogs/unreleased/fix-schedule-head-pipeline-update-method.yml
0 → 100644
View file @
5241a140
---
title
:
Fix update head pipeline process of Pipelines for merge requests
merge_request
:
28057
author
:
type
:
fixed
spec/services/ci/create_pipeline_service_spec.rb
View file @
5241a140
...
...
@@ -773,7 +773,7 @@ describe Ci::CreatePipelineService do
end
end
describe
'
Merge request pipeline
s'
do
describe
'
Pipelines for merge request
s'
do
let
(
:pipeline
)
do
execute_service
(
source:
source
,
merge_request:
merge_request
,
...
...
@@ -817,12 +817,14 @@ describe Ci::CreatePipelineService do
let
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
source_branch:
Gitlab
::
Git
.
ref_name
(
ref_name
)
,
source_branch:
'feature'
,
target_project:
project
,
target_branch:
'master'
)
end
it
'creates a merge request pipeline'
do
let
(
:ref_name
)
{
merge_request
.
ref_path
}
it
'creates a detached merge request pipeline'
do
expect
(
pipeline
).
to
be_persisted
expect
(
pipeline
).
to
be_merge_request_event
expect
(
pipeline
.
merge_request
).
to
eq
(
merge_request
)
...
...
@@ -837,6 +839,13 @@ describe Ci::CreatePipelineService do
expect
(
pipeline
.
target_sha
).
to
be_nil
end
it
'schedules update for the head pipeline of the merge request'
do
expect
(
UpdateHeadPipelineForMergeRequestWorker
)
.
to
receive
(
:perform_async
).
with
(
merge_request
.
id
)
pipeline
end
context
'when target sha is specified'
do
let
(
:target_sha
)
{
merge_request
.
target_branch_sha
}
...
...
@@ -858,15 +867,16 @@ describe Ci::CreatePipelineService do
let
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
source_branch:
Gitlab
::
Git
.
ref_name
(
ref_name
)
,
source_branch:
'feature'
,
target_project:
target_project
,
target_branch:
'master'
)
end
let
(
:ref_name
)
{
'refs/heads/feature'
}
let!
(
:project
)
{
fork_project
(
target_project
,
nil
,
repository:
true
)
}
let!
(
:target_project
)
{
create
(
:project
,
:repository
)
}
it
'creates a merge request pipeline in the forked project'
do
it
'creates a
legacy detached
merge request pipeline in the forked project'
do
expect
(
pipeline
).
to
be_persisted
expect
(
project
.
ci_pipelines
).
to
eq
([
pipeline
])
expect
(
target_project
.
ci_pipelines
).
to
be_empty
...
...
@@ -884,7 +894,7 @@ describe Ci::CreatePipelineService do
}
end
it
'does not create a merge request pipeline'
do
it
'does not create a
detached
merge request pipeline'
do
expect
(
pipeline
).
not_to
be_persisted
expect
(
pipeline
.
errors
[
:base
]).
to
eq
([
"No stages / jobs for this pipeline."
])
end
...
...
@@ -894,7 +904,7 @@ describe Ci::CreatePipelineService do
context
'when merge request is not specified'
do
let
(
:merge_request
)
{
nil
}
it
'does not create a merge request pipeline'
do
it
'does not create a
detached
merge request pipeline'
do
expect
(
pipeline
).
not_to
be_persisted
expect
(
pipeline
.
errors
[
:merge_request
]).
to
eq
([
"can't be blank"
])
end
...
...
@@ -928,7 +938,7 @@ describe Ci::CreatePipelineService do
target_branch:
'master'
)
end
it
'does not create a merge request pipeline'
do
it
'does not create a
detached
merge request pipeline'
do
expect
(
pipeline
).
not_to
be_persisted
expect
(
pipeline
.
errors
[
:base
])
...
...
@@ -939,7 +949,7 @@ describe Ci::CreatePipelineService do
context
'when merge request is not specified'
do
let
(
:merge_request
)
{
nil
}
it
'does not create a merge request pipeline'
do
it
'does not create a
detached
merge request pipeline'
do
expect
(
pipeline
).
not_to
be_persisted
expect
(
pipeline
.
errors
[
:base
])
...
...
@@ -968,7 +978,7 @@ describe Ci::CreatePipelineService do
target_branch:
'master'
)
end
it
'does not create a merge request pipeline'
do
it
'does not create a
detached
merge request pipeline'
do
expect
(
pipeline
).
not_to
be_persisted
expect
(
pipeline
.
errors
[
:base
])
...
...
@@ -999,7 +1009,7 @@ describe Ci::CreatePipelineService do
target_branch:
'master'
)
end
it
'does not create a merge request pipeline'
do
it
'does not create a
detached
merge request pipeline'
do
expect
(
pipeline
).
not_to
be_persisted
expect
(
pipeline
.
errors
[
:base
])
...
...
@@ -1028,7 +1038,7 @@ describe Ci::CreatePipelineService do
target_branch:
'master'
)
end
it
'does not create a merge request pipeline'
do
it
'does not create a
detached
merge request pipeline'
do
expect
(
pipeline
).
not_to
be_persisted
expect
(
pipeline
.
errors
[
:base
])
...
...
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