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
f0d59b95
Commit
f0d59b95
authored
Apr 17, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate presence of a stage index in the model
parent
43dd213b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
4 deletions
+11
-4
app/models/ci/stage.rb
app/models/ci/stage.rb
+6
-3
app/services/ci/ensure_stage_service.rb
app/services/ci/ensure_stage_service.rb
+1
-0
lib/gitlab/ci/pipeline/seed/stage.rb
lib/gitlab/ci/pipeline/seed/stage.rb
+1
-0
spec/factories/ci/stages.rb
spec/factories/ci/stages.rb
+1
-0
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+2
-1
No files found.
app/models/ci/stage.rb
View file @
f0d59b95
...
...
@@ -13,9 +13,12 @@ module Ci
has_many
:statuses
,
class_name:
'CommitStatus'
,
foreign_key: :stage_id
has_many
:builds
,
foreign_key: :stage_id
validates
:project
,
presence:
true
,
unless: :importing?
validates
:pipeline
,
presence:
true
,
unless: :importing?
validates
:name
,
presence:
true
,
unless: :importing?
with_options
unless: :importing?
do
validates
:project
,
presence:
true
validates
:pipeline
,
presence:
true
validates
:name
,
presence:
true
validates
:index
,
presence:
true
end
after_initialize
do
|
stage
|
self
.
status
=
DEFAULT_STATUS
if
self
.
status
.
nil?
...
...
app/services/ci/ensure_stage_service.rb
View file @
f0d59b95
...
...
@@ -42,6 +42,7 @@ module Ci
def
create_stage
Ci
::
Stage
.
create!
(
name:
@build
.
stage
,
index:
@build
.
stage_idx
,
pipeline:
@build
.
pipeline
,
project:
@build
.
project
)
end
...
...
lib/gitlab/ci/pipeline/seed/stage.rb
View file @
f0d59b95
...
...
@@ -19,6 +19,7 @@ module Gitlab
def
attributes
{
name:
@attributes
.
fetch
(
:name
),
index:
@attributes
.
fetch
(
:index
),
pipeline:
@pipeline
,
project:
@pipeline
.
project
}
end
...
...
spec/factories/ci/stages.rb
View file @
f0d59b95
...
...
@@ -21,6 +21,7 @@ FactoryBot.define do
pipeline
factory: :ci_empty_pipeline
name
'test'
index
1
status
'pending'
end
end
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
View file @
f0d59b95
...
...
@@ -24,7 +24,8 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
describe
'#attributes'
do
it
'returns hash attributes of a stage'
do
expect
(
subject
.
attributes
).
to
be_a
Hash
expect
(
subject
.
attributes
).
to
include
(
:name
,
:project
)
expect
(
subject
.
attributes
)
.
to
include
(
:name
,
:index
,
:pipeline
,
:project
)
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