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
iv
gitlab-ce
Commits
3579edba
Commit
3579edba
authored
Jun 10, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ci_commit -> pipeline
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
5324c936
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
20 deletions
+20
-20
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/views/projects/merge_requests/widget/_open.html.haml
app/views/projects/merge_requests/widget/_open.html.haml
+1
-1
spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb
...ures/merge_requests/only_allow_merge_if_build_succeeds.rb
+7
-7
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+11
-11
No files found.
app/models/merge_request.rb
View file @
3579edba
...
@@ -493,7 +493,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -493,7 +493,7 @@ class MergeRequest < ActiveRecord::Base
def
mergeable_ci_state?
def
mergeable_ci_state?
return
true
unless
project
.
only_allow_merge_if_build_succeeds?
return
true
unless
project
.
only_allow_merge_if_build_succeeds?
!
ci_commit
||
ci_commit
.
success?
!
pipeline
||
pipeline
.
success?
end
end
def
state_human_name
def
state_human_name
...
...
app/views/projects/merge_requests/widget/_open.html.haml
View file @
3579edba
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
=
render
'projects/merge_requests/widget/open/merge_when_build_succeeds'
=
render
'projects/merge_requests/widget/open/merge_when_build_succeeds'
-
elsif
!
@merge_request
.
can_be_merged_by?
(
current_user
)
-
elsif
!
@merge_request
.
can_be_merged_by?
(
current_user
)
=
render
'projects/merge_requests/widget/open/not_allowed'
=
render
'projects/merge_requests/widget/open/not_allowed'
-
elsif
!
@merge_request
.
mergeable_ci_state?
&&
@
ci_commit
&&
@ci_commit
.
failed?
-
elsif
!
@merge_request
.
mergeable_ci_state?
&&
@
pipeline
&&
@pipeline
.
failed?
=
render
'projects/merge_requests/widget/open/build_failed'
=
render
'projects/merge_requests/widget/open/build_failed'
-
elsif
@merge_request
.
can_be_merged?
-
elsif
@merge_request
.
can_be_merged?
=
render
'projects/merge_requests/widget/open/accept'
=
render
'projects/merge_requests/widget/open/accept'
...
...
spec/features/merge_requests/only_allow_merge_if_build_succeeds.rb
View file @
3579edba
...
@@ -19,7 +19,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
...
@@ -19,7 +19,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
end
end
context
'when project has CI enabled'
do
context
'when project has CI enabled'
do
let
(
:
ci_commit
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
)
}
let
(
:
pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
)
}
context
'when merge requests can only be merged if the build succeeds'
do
context
'when merge requests can only be merged if the build succeeds'
do
before
do
before
do
...
@@ -27,7 +27,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
...
@@ -27,7 +27,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
end
end
context
'when CI is running'
do
context
'when CI is running'
do
before
{
ci_commit
.
update_column
(
:status
,
:running
)
}
before
{
pipeline
.
update_column
(
:status
,
:running
)
}
it
'does not allow to merge immediately'
do
it
'does not allow to merge immediately'
do
visit_merge_request
(
merge_request
)
visit_merge_request
(
merge_request
)
...
@@ -38,7 +38,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
...
@@ -38,7 +38,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
end
end
context
'when CI failed'
do
context
'when CI failed'
do
before
{
ci_commit
.
update_column
(
:status
,
:failed
)
}
before
{
pipeline
.
update_column
(
:status
,
:failed
)
}
it
'does not allow MR to be merged'
do
it
'does not allow MR to be merged'
do
visit_merge_request
(
merge_request
)
visit_merge_request
(
merge_request
)
...
@@ -49,7 +49,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
...
@@ -49,7 +49,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
end
end
context
'when CI succeeded'
do
context
'when CI succeeded'
do
before
{
ci_commit
.
update_column
(
:status
,
:success
)
}
before
{
pipeline
.
update_column
(
:status
,
:success
)
}
it
'allows MR to be merged'
do
it
'allows MR to be merged'
do
visit_merge_request
(
merge_request
)
visit_merge_request
(
merge_request
)
...
@@ -65,7 +65,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
...
@@ -65,7 +65,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
end
end
context
'when CI is running'
do
context
'when CI is running'
do
before
{
ci_commit
.
update_column
(
:status
,
:running
)
}
before
{
pipeline
.
update_column
(
:status
,
:running
)
}
it
'allows MR to be merged immediately'
,
js:
true
do
it
'allows MR to be merged immediately'
,
js:
true
do
visit_merge_request
(
merge_request
)
visit_merge_request
(
merge_request
)
...
@@ -78,7 +78,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
...
@@ -78,7 +78,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
end
end
context
'when CI failed'
do
context
'when CI failed'
do
before
{
ci_commit
.
update_column
(
:status
,
:failed
)
}
before
{
pipeline
.
update_column
(
:status
,
:failed
)
}
it
'allows MR to be merged'
do
it
'allows MR to be merged'
do
visit_merge_request
(
merge_request
)
visit_merge_request
(
merge_request
)
...
@@ -88,7 +88,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
...
@@ -88,7 +88,7 @@ feature 'Only allow merge requests to be merged if the build succeeds', feature:
end
end
context
'when CI succeeded'
do
context
'when CI succeeded'
do
before
{
ci_commit
.
update_column
(
:status
,
:success
)
}
before
{
pipeline
.
update_column
(
:status
,
:success
)
}
it
'allows MR to be merged'
do
it
'allows MR to be merged'
do
visit_merge_request
(
merge_request
)
visit_merge_request
(
merge_request
)
...
...
spec/models/merge_request_spec.rb
View file @
3579edba
...
@@ -564,23 +564,23 @@ describe MergeRequest, models: true do
...
@@ -564,23 +564,23 @@ describe MergeRequest, models: true do
describe
'#mergeable_ci_state?'
do
describe
'#mergeable_ci_state?'
do
let
(
:project
)
{
create
(
:empty_project
,
only_allow_merge_if_build_succeeds:
true
)
}
let
(
:project
)
{
create
(
:empty_project
,
only_allow_merge_if_build_succeeds:
true
)
}
let
(
:
ci_commit
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:
pipeline
)
{
create
(
:ci_empty_pipeline
)
}
subject
{
build
(
:merge_request
,
target_project:
project
)
}
subject
{
build
(
:merge_request
,
target_project:
project
)
}
context
'when it is only allowed to merge when build is green'
do
context
'when it is only allowed to merge when build is green'
do
context
'and a failed
ci_commit
is associated'
do
context
'and a failed
pipeline
is associated'
do
before
do
before
do
ci_commit
.
statuses
<<
create
(
:commit_status
,
status:
'failed'
,
project:
project
)
pipeline
.
statuses
<<
create
(
:commit_status
,
status:
'failed'
,
project:
project
)
allow
(
subject
).
to
receive
(
:
ci_commit
)
{
ci_commit
}
allow
(
subject
).
to
receive
(
:
pipeline
)
{
pipeline
}
end
end
it
{
expect
(
subject
.
mergeable_ci_state?
).
to
be_falsey
}
it
{
expect
(
subject
.
mergeable_ci_state?
).
to
be_falsey
}
end
end
context
'when no
ci_commit
is associated'
do
context
'when no
pipeline
is associated'
do
before
do
before
do
allow
(
subject
).
to
receive
(
:
ci_commit
)
{
nil
}
allow
(
subject
).
to
receive
(
:
pipeline
)
{
nil
}
end
end
it
{
expect
(
subject
.
mergeable_ci_state?
).
to
be_truthy
}
it
{
expect
(
subject
.
mergeable_ci_state?
).
to
be_truthy
}
...
@@ -590,18 +590,18 @@ describe MergeRequest, models: true do
...
@@ -590,18 +590,18 @@ describe MergeRequest, models: true do
context
'when merges are not restricted to green builds'
do
context
'when merges are not restricted to green builds'
do
subject
{
build
(
:merge_request
,
target_project:
build
(
:empty_project
,
only_allow_merge_if_build_succeeds:
false
))
}
subject
{
build
(
:merge_request
,
target_project:
build
(
:empty_project
,
only_allow_merge_if_build_succeeds:
false
))
}
context
'and a failed
ci_commit
is associated'
do
context
'and a failed
pipeline
is associated'
do
before
do
before
do
ci_commit
.
statuses
<<
create
(
:commit_status
,
status:
'failed'
,
project:
project
)
pipeline
.
statuses
<<
create
(
:commit_status
,
status:
'failed'
,
project:
project
)
allow
(
subject
).
to
receive
(
:
ci_commit
)
{
ci_commit
}
allow
(
subject
).
to
receive
(
:
pipeline
)
{
pipeline
}
end
end
it
{
expect
(
subject
.
mergeable_ci_state?
).
to
be_truthy
}
it
{
expect
(
subject
.
mergeable_ci_state?
).
to
be_truthy
}
end
end
context
'when no
ci_commit
is associated'
do
context
'when no
pipeline
is associated'
do
before
do
before
do
allow
(
subject
).
to
receive
(
:
ci_commit
)
{
nil
}
allow
(
subject
).
to
receive
(
:
pipeline
)
{
nil
}
end
end
it
{
expect
(
subject
.
mergeable_ci_state?
).
to
be_truthy
}
it
{
expect
(
subject
.
mergeable_ci_state?
).
to
be_truthy
}
...
...
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