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
6a2f8a9a
Commit
6a2f8a9a
authored
Apr 18, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that an imported pipeline stage can be updated
parent
10df7014
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
app/models/ci/stage.rb
app/models/ci/stage.rb
+9
-1
spec/models/ci/stage_spec.rb
spec/models/ci/stage_spec.rb
+18
-1
No files found.
app/models/ci/stage.rb
View file @
6a2f8a9a
...
...
@@ -20,10 +20,18 @@ module Ci
validates
:index
,
presence:
true
end
after_initialize
do
|
stage
|
after_initialize
do
self
.
status
=
DEFAULT_STATUS
if
self
.
status
.
nil?
end
before_validation
do
next
unless
index
.
nil?
statuses
.
pluck
(
:stage_idx
).
tap
do
|
indices
|
self
.
index
=
indices
.
max_by
{
|
index
|
indices
.
count
(
index
)
}
end
end
state_machine
:status
,
initial: :created
do
event
:enqueue
do
transition
created: :pending
...
...
spec/models/ci/stage_spec.rb
View file @
6a2f8a9a
...
...
@@ -51,7 +51,7 @@ describe Ci::Stage, :models do
end
end
describe
'update_status'
do
describe
'
#
update_status'
do
context
'when stage objects needs to be updated'
do
before
do
create
(
:ci_build
,
:success
,
stage_id:
stage
.
id
)
...
...
@@ -87,4 +87,21 @@ describe Ci::Stage, :models do
end
end
end
describe
'#index'
do
context
'when stage has been imported and does not have index set'
do
before
do
create
(
:ci_build
,
:running
,
stage_id:
stage
.
id
,
stage_idx:
10
)
stage
.
update_column
(
:index
,
nil
)
end
it
'recalculates index before updating status'
do
expect
(
stage
.
reload
.
index
).
to
be_nil
stage
.
update_status
expect
(
stage
.
reload
.
index
).
to
eq
10
end
end
end
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