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
Léo-Paul Géneau
gitlab-ce
Commits
f62dc67d
Commit
f62dc67d
authored
Feb 25, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add suffix for merge request event
Fix ok Add spec Fix ok Fix Add changelog Fix Add memoization a fix
parent
dc5fc283
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
85 additions
and
62 deletions
+85
-62
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+10
-10
app/models/ci/pipeline_enums.rb
app/models/ci/pipeline_enums.rb
+1
-1
app/models/concerns/has_ref.rb
app/models/concerns/has_ref.rb
+1
-1
app/presenters/ci/build_runner_presenter.rb
app/presenters/ci/build_runner_presenter.rb
+1
-1
app/serializers/pipeline_entity.rb
app/serializers/pipeline_entity.rb
+2
-2
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+1
-1
app/views/projects/pipelines/_info.html.haml
app/views/projects/pipelines/_info.html.haml
+1
-1
changelogs/unreleased/refactor-merge-request-between-pipeline-and-build.yml
...sed/refactor-merge-request-between-pipeline-and-build.yml
+5
-0
lib/gitlab/ci/build/policy/refs.rb
lib/gitlab/ci/build/policy/refs.rb
+6
-2
spec/factories/merge_requests.rb
spec/factories/merge_requests.rb
+1
-1
spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb
...s/merge_request/user_sees_merge_request_pipelines_spec.rb
+4
-4
spec/features/projects/pipelines/pipeline_spec.rb
spec/features/projects/pipelines/pipeline_spec.rb
+1
-1
spec/lib/gitlab/ci/build/policy/changes_spec.rb
spec/lib/gitlab/ci/build/policy/changes_spec.rb
+1
-1
spec/lib/gitlab/ci/build/policy/refs_spec.rb
spec/lib/gitlab/ci/build/policy/refs_spec.rb
+14
-0
spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
+2
-2
spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+20
-20
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+3
-3
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+1
-1
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+2
-2
spec/services/merge_requests/create_service_spec.rb
spec/services/merge_requests/create_service_spec.rb
+2
-2
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+2
-2
spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb
...ers/update_head_pipeline_for_merge_request_worker_spec.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
f62dc67d
...
...
@@ -46,7 +46,7 @@ module Ci
delegate
:terminal_specification
,
to: :runner_session
,
allow_nil:
true
delegate
:gitlab_deploy_token
,
to: :project
delegate
:trigger_short_token
,
to: :trigger_request
,
allow_nil:
true
delegate
:merge_request?
,
to: :pipeline
delegate
:merge_request
_event
?
,
to: :pipeline
##
# Since Gitlab 11.5, deployments records started being created right after
...
...
app/models/ci/pipeline.rb
View file @
f62dc67d
...
...
@@ -60,9 +60,9 @@ module Ci
validates
:sha
,
presence:
{
unless: :importing?
}
validates
:ref
,
presence:
{
unless: :importing?
}
validates
:merge_request
,
presence:
{
if: :merge_request?
}
validates
:merge_request
,
absence:
{
unless: :merge_request?
}
validates
:tag
,
inclusion:
{
in:
[
false
],
if: :merge_request?
}
validates
:merge_request
,
presence:
{
if: :merge_request
_event
?
}
validates
:merge_request
,
absence:
{
unless: :merge_request
_event
?
}
validates
:tag
,
inclusion:
{
in:
[
false
],
if: :merge_request
_event
?
}
validates
:status
,
presence:
{
unless: :importing?
}
validate
:valid_commit_sha
,
unless: :importing?
validates
:source
,
exclusion:
{
in:
%w(unknown)
,
unless: :importing?
},
on: :create
...
...
@@ -179,7 +179,7 @@ module Ci
scope
:sort_by_merge_request_pipelines
,
->
do
sql
=
'CASE ci_pipelines.source WHEN (?) THEN 0 ELSE 1 END, ci_pipelines.id DESC'
query
=
ActiveRecord
::
Base
.
send
(
:sanitize_sql_array
,
[
sql
,
sources
[
:merge_request
]])
# rubocop:disable GitlabSecurity/PublicSend
query
=
ActiveRecord
::
Base
.
send
(
:sanitize_sql_array
,
[
sql
,
sources
[
:merge_request
_event
]])
# rubocop:disable GitlabSecurity/PublicSend
order
(
query
)
end
...
...
@@ -196,7 +196,7 @@ module Ci
end
scope
:triggered_by_merge_request
,
->
(
merge_request
)
do
where
(
source: :merge_request
,
merge_request:
merge_request
)
where
(
source: :merge_request
_event
,
merge_request:
merge_request
)
end
scope
:detached_merge_request_pipelines
,
->
(
merge_request
)
do
...
...
@@ -639,7 +639,7 @@ module Ci
variables
.
append
(
key:
'CI_COMMIT_TITLE'
,
value:
git_commit_full_title
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_DESCRIPTION'
,
value:
git_commit_description
.
to_s
)
if
merge_request?
&&
merge_request
if
merge_request
_event
?
&&
merge_request
variables
.
append
(
key:
'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA'
,
value:
source_sha
.
to_s
)
variables
.
append
(
key:
'CI_MERGE_REQUEST_TARGET_BRANCH_SHA'
,
value:
target_sha
.
to_s
)
variables
.
concat
(
merge_request
.
predefined_variables
)
...
...
@@ -669,7 +669,7 @@ module Ci
# All the merge requests for which the current pipeline runs/ran against
def
all_merge_requests
@all_merge_requests
||=
if
merge_request?
if
merge_request
_event
?
MergeRequest
.
where
(
id:
merge_request_id
)
else
MergeRequest
.
where
(
source_project_id:
project_id
,
source_branch:
ref
)
...
...
@@ -714,7 +714,7 @@ module Ci
# * nil: Modified path can not be evaluated
def
modified_paths
strong_memoize
(
:modified_paths
)
do
if
merge_request?
if
merge_request
_event
?
merge_request
.
modified_paths
elsif
branch_updated?
push_details
.
modified_paths
...
...
@@ -727,7 +727,7 @@ module Ci
end
def
triggered_by_merge_request?
merge_request?
&&
merge_request_id
.
present?
merge_request
_event
?
&&
merge_request_id
.
present?
end
def
detached_merge_request_pipeline?
...
...
@@ -773,7 +773,7 @@ module Ci
end
def
git_ref
if
merge_request?
if
merge_request
_event
?
##
# In the future, we're going to change this ref to
# merge request's merged reference, such as "refs/merge-requests/:iid/merge".
...
...
app/models/ci/pipeline_enums.rb
View file @
f62dc67d
...
...
@@ -23,7 +23,7 @@ module Ci
api:
5
,
external:
6
,
chat:
8
,
merge_request:
10
merge_request
_event
:
10
}
end
...
...
app/models/concerns/has_ref.rb
View file @
f62dc67d
...
...
@@ -4,7 +4,7 @@ module HasRef
extend
ActiveSupport
::
Concern
def
branch?
!
tag?
&&
!
merge_request?
!
tag?
&&
!
merge_request
_event
?
end
def
git_ref
...
...
app/presenters/ci/build_runner_presenter.rb
View file @
f62dc67d
...
...
@@ -35,7 +35,7 @@ module Ci
specs
=
[]
if
git_depth
>
0
specs
<<
refspec_for_branch
(
ref
)
if
branch?
||
merge_request?
specs
<<
refspec_for_branch
(
ref
)
if
branch?
||
merge_request
_event
?
specs
<<
refspec_for_tag
(
ref
)
if
tag?
else
specs
<<
refspec_for_branch
...
...
app/serializers/pipeline_entity.rb
View file @
f62dc67d
...
...
@@ -23,7 +23,7 @@ class PipelineEntity < Grape::Entity
expose
:latest?
,
as: :latest
expose
:stuck?
,
as: :stuck
expose
:auto_devops_source?
,
as: :auto_devops
expose
:merge_request?
,
as: :merge_request
expose
:merge_request
_event
?
,
as: :merge_request
expose
:has_yaml_errors?
,
as: :yaml_errors
expose
:can_retry?
,
as: :retryable
expose
:can_cancel?
,
as: :cancelable
...
...
@@ -49,7 +49,7 @@ class PipelineEntity < Grape::Entity
expose
:tag?
,
as: :tag
expose
:branch?
,
as: :branch
expose
:merge_request?
,
as: :merge_request
expose
:merge_request
_event
?
,
as: :merge_request
end
expose
:commit
,
using:
CommitEntity
...
...
app/services/merge_requests/base_service.rb
View file @
f62dc67d
...
...
@@ -67,7 +67,7 @@ module MergeRequests
Ci
::
CreatePipelineService
.
new
(
merge_request
.
source_project
,
user
,
ref:
merge_request
.
source_branch
)
.
execute
(
:merge_request
,
.
execute
(
:merge_request
_event
,
ignore_skip_ci:
true
,
save_on_errors:
false
,
merge_request:
merge_request
)
...
...
app/views/projects/pipelines/_info.html.haml
View file @
f62dc67d
...
...
@@ -48,7 +48,7 @@
content:
"<a class='autodevops-link' href='#{popover_content_url}' target='_blank' rel='noopener noreferrer nofollow'>#{popover_content_text}</a>"
,
}
}
Auto
DevOps
-
if
@pipeline
.
merge_request?
-
if
@pipeline
.
merge_request
_event
?
%span
.js-pipeline-url-mergerequest.badge.badge-info.has-tooltip
{
title:
"This pipeline is run in a merge request context"
}
merge
request
-
if
@pipeline
.
stuck?
...
...
changelogs/unreleased/refactor-merge-request-between-pipeline-and-build.yml
0 → 100644
View file @
f62dc67d
---
title
:
Add suffix (`_event`) to merge request source
merge_request
:
25508
author
:
type
:
other
lib/gitlab/ci/build/policy/refs.rb
View file @
f62dc67d
...
...
@@ -29,8 +29,8 @@ module Gitlab
def
matches_pattern?
(
pattern
,
pipeline
)
return
true
if
pipeline
.
tag?
&&
pattern
==
'tags'
return
true
if
pipeline
.
branch?
&&
pattern
==
'branches'
return
true
if
pipeline
.
source
==
pattern
return
true
if
pipeline
.
source
&
.
pluralize
==
pattern
return
true
if
sanitized_source_name
(
pipeline
)
==
pattern
return
true
if
sanitized_source_name
(
pipeline
)
&
.
pluralize
==
pattern
# patterns can be matched only when branch or tag is used
# the pattern matching does not work for merge requests pipelines
...
...
@@ -42,6 +42,10 @@ module Gitlab
end
end
end
def
sanitized_source_name
(
pipeline
)
@sanitized_source_name
||=
pipeline
&
.
source
&
.
delete_suffix
(
'_event'
)
end
end
end
end
...
...
spec/factories/merge_requests.rb
View file @
f62dc67d
...
...
@@ -104,7 +104,7 @@ FactoryBot.define do
trait
:with_merge_request_pipeline
do
after
(
:build
)
do
|
merge_request
|
merge_request
.
merge_request_pipelines
<<
build
(
:ci_pipeline
,
source: :merge_request
,
source: :merge_request
_event
,
merge_request:
merge_request
,
project:
merge_request
.
source_project
)
end
...
...
spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb
View file @
f62dc67d
...
...
@@ -49,7 +49,7 @@ describe 'Merge request > User sees merge request pipelines', :js do
let!
(
:merge_request_pipeline
)
do
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
ref:
'feature'
)
.
execute
(
:merge_request
,
merge_request:
merge_request
)
.
execute
(
:merge_request
_event
,
merge_request:
merge_request
)
end
before
do
...
...
@@ -81,7 +81,7 @@ describe 'Merge request > User sees merge request pipelines', :js do
let!
(
:merge_request_pipeline_2
)
do
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
ref:
'feature'
)
.
execute
(
:merge_request
,
merge_request:
merge_request
)
.
execute
(
:merge_request
_event
,
merge_request:
merge_request
)
end
before
do
...
...
@@ -220,7 +220,7 @@ describe 'Merge request > User sees merge request pipelines', :js do
let!
(
:merge_request_pipeline
)
do
Ci
::
CreatePipelineService
.
new
(
forked_project
,
user2
,
ref:
'feature'
)
.
execute
(
:merge_request
,
merge_request:
merge_request
)
.
execute
(
:merge_request
_event
,
merge_request:
merge_request
)
end
let
(
:forked_project
)
{
fork_project
(
project
,
user2
,
repository:
true
)
}
...
...
@@ -263,7 +263,7 @@ describe 'Merge request > User sees merge request pipelines', :js do
let!
(
:merge_request_pipeline_2
)
do
Ci
::
CreatePipelineService
.
new
(
forked_project
,
user2
,
ref:
'feature'
)
.
execute
(
:merge_request
,
merge_request:
merge_request
)
.
execute
(
:merge_request
_event
,
merge_request:
merge_request
)
end
before
do
...
...
spec/features/projects/pipelines/pipeline_spec.rb
View file @
f62dc67d
...
...
@@ -666,7 +666,7 @@ describe 'Pipeline', :js do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
source: :merge_request
_event
,
project:
merge_request
.
source_project
,
ref:
'feature'
,
sha:
merge_request
.
diff_head_sha
,
...
...
spec/lib/gitlab/ci/build/policy/changes_spec.rb
View file @
f62dc67d
...
...
@@ -133,7 +133,7 @@ describe Gitlab::Ci::Build::Policy::Changes do
let
(
:seed
)
{
double
(
'build seed'
,
to_resource:
ci_build
)
}
context
'when source is merge request'
do
let
(
:source
)
{
:merge_request
}
let
(
:source
)
{
:merge_request
_event
}
let
(
:merge_request
)
do
create
(
:merge_request
,
...
...
spec/lib/gitlab/ci/build/policy/refs_spec.rb
View file @
f62dc67d
...
...
@@ -68,6 +68,20 @@ describe Gitlab::Ci::Build::Policy::Refs do
expect
(
described_class
.
new
(
%w[triggers]
))
.
not_to
be_satisfied_by
(
pipeline
)
end
context
'when source is merge_request_event'
do
let
(
:pipeline
)
{
build_stubbed
(
:ci_pipeline
,
source: :merge_request_event
)
}
it
'is satisfied with only: merge_request'
do
expect
(
described_class
.
new
(
%w[merge_requests]
))
.
to
be_satisfied_by
(
pipeline
)
end
it
'is not satisfied with only: merge_request_event'
do
expect
(
described_class
.
new
(
%w[merge_request_events]
))
.
not_to
be_satisfied_by
(
pipeline
)
end
end
end
context
'when matching a ref by a regular expression'
do
...
...
spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
View file @
f62dc67d
...
...
@@ -96,7 +96,7 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
context
'when pipeline is running for a merge request'
do
let
(
:command
)
do
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Command
.
new
(
source: :merge_request
,
source: :merge_request
_event
,
origin_ref:
'feature'
,
checkout_sha:
project
.
commit
.
id
,
after_sha:
nil
,
...
...
@@ -117,7 +117,7 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
end
it
'correctly indicated that this is a merge request pipeline'
do
expect
(
pipeline
).
to
be_merge_request
expect
(
pipeline
).
to
be_merge_request
_event
expect
(
pipeline
.
merge_request
).
to
eq
(
merge_request
)
end
...
...
spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
View file @
f62dc67d
...
...
@@ -115,7 +115,7 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
let
(
:pipeline
)
{
build_stubbed
(
:ci_pipeline
,
project:
project
)
}
let
(
:merge_request_pipeline
)
do
build
(
:ci_pipeline
,
source: :merge_request
,
project:
project
)
build
(
:ci_pipeline
,
source: :merge_request
_event
,
project:
project
)
end
let
(
:chain
)
{
described_class
.
new
(
merge_request_pipeline
,
command
).
tap
(
&
:perform!
)
}
...
...
spec/models/ci/build_spec.rb
View file @
f62dc67d
...
...
@@ -23,7 +23,7 @@ describe Ci::Build do
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
respond_to
(
:has_trace?
)
}
it
{
is_expected
.
to
respond_to
(
:trace
)
}
it
{
is_expected
.
to
delegate_method
(
:merge_request?
).
to
(
:pipeline
)
}
it
{
is_expected
.
to
delegate_method
(
:merge_request
_event
?
).
to
(
:pipeline
)
}
it
{
is_expected
.
to
be_a
(
ArtifactMigratable
)
}
...
...
spec/models/ci/pipeline_spec.rb
View file @
f62dc67d
...
...
@@ -80,11 +80,11 @@ describe Ci::Pipeline, :mailer do
context
'when merge request pipelines exist'
do
let!
(
:merge_request_pipeline_1
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
)
end
let!
(
:merge_request_pipeline_2
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
)
end
let
(
:merge_request
)
do
...
...
@@ -106,11 +106,11 @@ describe Ci::Pipeline, :mailer do
let!
(
:branch_pipeline_2
)
{
create
(
:ci_pipeline
,
source: :push
)
}
let!
(
:merge_request_pipeline_1
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
)
end
let!
(
:merge_request_pipeline_2
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
)
end
let
(
:merge_request
)
do
...
...
@@ -134,7 +134,7 @@ describe Ci::Pipeline, :mailer do
subject
{
described_class
.
detached_merge_request_pipelines
(
merge_request
)
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
,
target_sha:
target_sha
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
,
target_sha:
target_sha
)
end
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
...
@@ -157,7 +157,7 @@ describe Ci::Pipeline, :mailer do
subject
{
pipeline
.
detached_merge_request_pipeline?
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
,
target_sha:
target_sha
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
,
target_sha:
target_sha
)
end
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
...
@@ -176,7 +176,7 @@ describe Ci::Pipeline, :mailer do
subject
{
described_class
.
merge_request_pipelines
(
merge_request
)
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
,
target_sha:
target_sha
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
,
target_sha:
target_sha
)
end
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
...
@@ -199,7 +199,7 @@ describe Ci::Pipeline, :mailer do
subject
{
pipeline
.
merge_request_pipeline?
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
,
target_sha:
target_sha
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
,
target_sha:
target_sha
)
end
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
...
@@ -218,7 +218,7 @@ describe Ci::Pipeline, :mailer do
subject
{
described_class
.
mergeable_merge_request_pipelines
(
merge_request
)
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
,
target_sha:
target_sha
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
,
target_sha:
target_sha
)
end
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
...
@@ -241,7 +241,7 @@ describe Ci::Pipeline, :mailer do
subject
{
pipeline
.
mergeable_merge_request_pipeline?
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
,
target_sha:
target_sha
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
,
target_sha:
target_sha
)
end
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
...
@@ -256,11 +256,11 @@ describe Ci::Pipeline, :mailer do
end
end
describe
'.merge_request'
do
subject
{
described_class
.
merge_request
}
describe
'.merge_request
_event
'
do
subject
{
described_class
.
merge_request
_event
}
context
'when there is a merge request pipeline'
do
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
)
}
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
it
'returns merge request pipeline first'
do
...
...
@@ -281,7 +281,7 @@ describe Ci::Pipeline, :mailer do
let
(
:pipeline
)
{
build
(
:ci_pipeline
,
source:
source
,
merge_request:
merge_request
)
}
context
'when source is merge request'
do
let
(
:source
)
{
:merge_request
}
let
(
:source
)
{
:merge_request
_event
}
context
'when merge request is specified'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
'feature'
,
target_project:
project
,
target_branch:
'master'
)
}
...
...
@@ -505,7 +505,7 @@ describe Ci::Pipeline, :mailer do
context
'when source is merge request'
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
)
end
let
(
:merge_request
)
do
...
...
@@ -1097,7 +1097,7 @@ describe Ci::Pipeline, :mailer do
context
'when source is merge request'
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
)
end
let
(
:merge_request
)
do
...
...
@@ -1147,7 +1147,7 @@ describe Ci::Pipeline, :mailer do
context
'when ref is merge request'
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
source: :merge_request
_event
,
merge_request:
merge_request
)
end
...
...
@@ -1310,7 +1310,7 @@ describe Ci::Pipeline, :mailer do
context
'when source is merge request'
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
merge_request:
merge_request
)
create
(
:ci_pipeline
,
source: :merge_request
_event
,
merge_request:
merge_request
)
end
let
(
:merge_request
)
do
...
...
@@ -2266,7 +2266,7 @@ describe Ci::Pipeline, :mailer do
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
source: :merge_request
_event
,
project:
pipeline_project
,
ref:
source_branch
,
merge_request:
merge_request
)
...
...
@@ -2289,7 +2289,7 @@ describe Ci::Pipeline, :mailer do
let!
(
:pipeline_2
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
source: :merge_request
_event
,
project:
pipeline_project
,
ref:
source_branch
,
merge_request:
merge_request_2
)
...
...
spec/models/merge_request_spec.rb
View file @
f62dc67d
...
...
@@ -1333,7 +1333,7 @@ describe MergeRequest do
let!
(
:merge_request_pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
source: :merge_request
_event
,
project:
project
,
ref:
source_ref
,
sha:
shas
.
second
,
...
...
@@ -1372,7 +1372,7 @@ describe MergeRequest do
let!
(
:merge_request_pipeline_2
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
source: :merge_request
_event
,
project:
project
,
ref:
source_ref
,
sha:
shas
.
first
,
...
...
@@ -1399,7 +1399,7 @@ describe MergeRequest do
let!
(
:merge_request_pipeline_2
)
do
create
(
:ci_pipeline
,
source: :merge_request
,
source: :merge_request
_event
,
project:
project
,
ref:
source_ref
,
sha:
shas
.
first
,
...
...
spec/requests/api/runner_spec.rb
View file @
f62dc67d
...
...
@@ -549,7 +549,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
context
'when job is made for merge request'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline_without_jobs
,
source: :merge_request
,
project:
project
,
ref:
'feature'
,
merge_request:
merge_request
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline_without_jobs
,
source: :merge_request
_event
,
project:
project
,
ref:
'feature'
,
merge_request:
merge_request
)
}
let!
(
:job
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'spinach'
,
ref:
'feature'
,
stage:
'test'
,
stage_idx:
0
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
f62dc67d
...
...
@@ -701,7 +701,7 @@ describe Ci::CreatePipelineService do
let
(
:target_sha
)
{
nil
}
context
'when source is merge request'
do
let
(
:source
)
{
:merge_request
}
let
(
:source
)
{
:merge_request
_event
}
context
"when config has merge_requests keywords"
do
let
(
:config
)
do
...
...
@@ -734,7 +734,7 @@ describe Ci::CreatePipelineService do
it
'creates a merge request pipeline'
do
expect
(
pipeline
).
to
be_persisted
expect
(
pipeline
).
to
be_merge_request
expect
(
pipeline
).
to
be_merge_request
_event
expect
(
pipeline
.
merge_request
).
to
eq
(
merge_request
)
expect
(
pipeline
.
builds
.
order
(
:stage_id
).
map
(
&
:name
)).
to
eq
(
%w[test]
)
end
...
...
spec/services/merge_requests/create_service_spec.rb
View file @
f62dc67d
...
...
@@ -194,7 +194,7 @@ describe MergeRequests::CreateService do
merge_request
.
reload
expect
(
merge_request
.
merge_request_pipelines
.
count
).
to
eq
(
1
)
expect
(
merge_request
.
actual_head_pipeline
).
to
be_merge_request
expect
(
merge_request
.
actual_head_pipeline
).
to
be_merge_request
_event
end
context
'when there are no commits between source branch and target branch'
do
...
...
@@ -226,7 +226,7 @@ describe MergeRequests::CreateService do
end
it
'sets the latest merge request pipeline as the head pipeline'
do
expect
(
merge_request
.
actual_head_pipeline
).
to
be_merge_request
expect
(
merge_request
.
actual_head_pipeline
).
to
be_merge_request
_event
end
end
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
f62dc67d
...
...
@@ -173,12 +173,12 @@ describe MergeRequests::RefreshService do
it
'sets the latest merge request pipeline as a head pipeline'
do
@merge_request
.
reload
expect
(
@merge_request
.
actual_head_pipeline
).
to
be_merge_request
expect
(
@merge_request
.
actual_head_pipeline
).
to
be_merge_request
_event
end
it
'returns pipelines in correct order'
do
@merge_request
.
reload
expect
(
@merge_request
.
all_pipelines
.
first
).
to
be_merge_request
expect
(
@merge_request
.
all_pipelines
.
first
).
to
be_merge_request
_event
expect
(
@merge_request
.
all_pipelines
.
second
).
to
be_push
end
end
...
...
spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb
View file @
f62dc67d
...
...
@@ -39,7 +39,7 @@ describe UpdateHeadPipelineForMergeRequestWorker do
let!
(
:merge_request_pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
source: :merge_request
,
source: :merge_request
_event
,
sha:
latest_sha
,
merge_request:
merge_request
)
end
...
...
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