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
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
Show 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
...
@@ -13,9 +13,12 @@ module Ci
has_many
:statuses
,
class_name:
'CommitStatus'
,
foreign_key: :stage_id
has_many
:statuses
,
class_name:
'CommitStatus'
,
foreign_key: :stage_id
has_many
:builds
,
foreign_key: :stage_id
has_many
:builds
,
foreign_key: :stage_id
validates
:project
,
presence:
true
,
unless: :importing?
with_options
unless: :importing?
do
validates
:pipeline
,
presence:
true
,
unless: :importing?
validates
:project
,
presence:
true
validates
:name
,
presence:
true
,
unless: :importing?
validates
:pipeline
,
presence:
true
validates
:name
,
presence:
true
validates
:index
,
presence:
true
end
after_initialize
do
|
stage
|
after_initialize
do
|
stage
|
self
.
status
=
DEFAULT_STATUS
if
self
.
status
.
nil?
self
.
status
=
DEFAULT_STATUS
if
self
.
status
.
nil?
...
...
app/services/ci/ensure_stage_service.rb
View file @
f0d59b95
...
@@ -42,6 +42,7 @@ module Ci
...
@@ -42,6 +42,7 @@ module Ci
def
create_stage
def
create_stage
Ci
::
Stage
.
create!
(
name:
@build
.
stage
,
Ci
::
Stage
.
create!
(
name:
@build
.
stage
,
index:
@build
.
stage_idx
,
pipeline:
@build
.
pipeline
,
pipeline:
@build
.
pipeline
,
project:
@build
.
project
)
project:
@build
.
project
)
end
end
...
...
lib/gitlab/ci/pipeline/seed/stage.rb
View file @
f0d59b95
...
@@ -19,6 +19,7 @@ module Gitlab
...
@@ -19,6 +19,7 @@ module Gitlab
def
attributes
def
attributes
{
name:
@attributes
.
fetch
(
:name
),
{
name:
@attributes
.
fetch
(
:name
),
index:
@attributes
.
fetch
(
:index
),
pipeline:
@pipeline
,
pipeline:
@pipeline
,
project:
@pipeline
.
project
}
project:
@pipeline
.
project
}
end
end
...
...
spec/factories/ci/stages.rb
View file @
f0d59b95
...
@@ -21,6 +21,7 @@ FactoryBot.define do
...
@@ -21,6 +21,7 @@ FactoryBot.define do
pipeline
factory: :ci_empty_pipeline
pipeline
factory: :ci_empty_pipeline
name
'test'
name
'test'
index
1
status
'pending'
status
'pending'
end
end
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
...
@@ -24,7 +24,8 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
describe
'#attributes'
do
describe
'#attributes'
do
it
'returns hash attributes of a stage'
do
it
'returns hash attributes of a stage'
do
expect
(
subject
.
attributes
).
to
be_a
Hash
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
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