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
Jérome Perrin
gitlab-ce
Commits
de4c9a27
Commit
de4c9a27
authored
Jul 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve CI stage configuration entry validations
parent
b228787f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
lib/gitlab/ci/config/node/stage.rb
lib/gitlab/ci/config/node/stage.rb
+9
-7
lib/gitlab/ci/config/node/validators.rb
lib/gitlab/ci/config/node/validators.rb
+1
-1
spec/lib/gitlab/ci/config/node/stage_spec.rb
spec/lib/gitlab/ci/config/node/stage_spec.rb
+2
-2
No files found.
lib/gitlab/ci/config/node/stage.rb
View file @
de4c9a27
...
@@ -10,14 +10,16 @@ module Gitlab
...
@@ -10,14 +10,16 @@ module Gitlab
validations
do
validations
do
validates
:config
,
type:
String
validates
:config
,
type:
String
validates
:global
,
required_attribute:
true
validate
:known_stage
,
on: :processed
def
known_stage
with_options
on: :processed
do
validates
:global
,
required:
true
validate
do
unless
known?
unless
known?
stages_list
=
global
.
stages
.
join
(
', '
)
errors
.
add
(
:config
,
errors
.
add
(
:config
,
"should be one of defined stages (
#{
stages_list
}
)"
)
'should be one of defined stages '
\
"(
#{
global
.
stages
.
join
(
', '
)
}
)"
)
end
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/node/validators.rb
View file @
de4c9a27
...
@@ -33,7 +33,7 @@ module Gitlab
...
@@ -33,7 +33,7 @@ module Gitlab
end
end
end
end
class
Required
Attribute
Validator
<
ActiveModel
::
EachValidator
class
RequiredValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
def
validate_each
(
record
,
attribute
,
value
)
if
value
.
nil?
if
value
.
nil?
raise
Entry
::
InvalidError
,
raise
Entry
::
InvalidError
,
...
...
spec/lib/gitlab/ci/config/node/stage_spec.rb
View file @
de4c9a27
...
@@ -28,10 +28,10 @@ describe Gitlab::Ci::Config::Node::Stage do
...
@@ -28,10 +28,10 @@ describe Gitlab::Ci::Config::Node::Stage do
context
'when stage config is incorrect'
do
context
'when stage config is incorrect'
do
describe
'#errors'
do
describe
'#errors'
do
context
'when reference to global node is not set'
do
context
'when reference to global node is not set'
do
let
(
:stage
)
{
described_class
.
new
(
config
)
}
let
(
:stage
)
{
described_class
.
new
(
'test'
)
}
it
'raises error'
do
it
'raises error'
do
expect
{
stage
}.
to
raise_error
(
expect
{
stage
.
validate!
}.
to
raise_error
(
Gitlab
::
Ci
::
Config
::
Node
::
Entry
::
InvalidError
,
Gitlab
::
Ci
::
Config
::
Node
::
Entry
::
InvalidError
,
/Entry needs global attribute set internally./
/Entry needs global attribute set internally./
)
)
...
...
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