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
Boxiang Sun
gitlab-ce
Commits
e2828a60
Commit
e2828a60
authored
Oct 06, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use existing pipeline stage if stage already exists
parent
503f2136
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
app/models/commit_status.rb
app/models/commit_status.rb
+11
-3
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+23
-0
No files found.
app/models/commit_status.rb
View file @
e2828a60
...
@@ -192,12 +192,20 @@ class CommitStatus < ActiveRecord::Base
...
@@ -192,12 +192,20 @@ class CommitStatus < ActiveRecord::Base
private
private
def
ensure_pipeline_stage!
def
ensure_pipeline_stage!
attributes
=
{
name:
stage
,
pipeline:
pipeline
,
project:
project
}
(
find_stage
||
create_stage!
).
tap
do
|
stage
|
Ci
::
Stage
.
create!
(
attributes
).
tap
do
|
stage
|
self
.
stage_id
=
stage
.
id
self
.
stage_id
=
stage
.
id
yield
stage
yield
stage
end
end
end
end
def
find_stage
pipeline
.
stages
.
find_by
(
name:
stage
)
end
def
create_stage!
Ci
::
Stage
.
create!
(
name:
stage
,
pipeline:
pipeline
,
project:
project
)
end
end
end
spec/models/commit_status_spec.rb
View file @
e2828a60
...
@@ -499,6 +499,29 @@ describe CommitStatus do
...
@@ -499,6 +499,29 @@ describe CommitStatus do
end
end
end
end
context
'when commit status does not have stage but it exists'
do
let!
(
:stage
)
do
create
(
:ci_stage_entity
,
project:
project
,
pipeline:
pipeline
,
name:
'test'
)
end
let
(
:commit_status
)
do
create
(
:commit_status
,
project:
project
,
pipeline:
pipeline
,
name:
'rspec'
,
stage:
'test'
,
status: :success
)
end
it
'uses existing stage'
do
expect
{
commit_status
}.
not_to
change
{
Ci
::
Stage
.
count
}
expect
(
commit_status
.
stage_id
).
to
eq
stage
.
id
expect
(
stage
.
reload
.
status
).
to
eq
commit_status
.
status
end
end
context
'when commit status is being imported'
do
context
'when commit status is being imported'
do
let
(
:commit_status
)
do
let
(
:commit_status
)
do
create
(
:commit_status
,
name:
'rspec'
,
stage:
'test'
,
importing:
true
)
create
(
:commit_status
,
name:
'rspec'
,
stage:
'test'
,
importing:
true
)
...
...
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