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
8baee987
Commit
8baee987
authored
Jul 08, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract internal attributes validator for CI entry
parent
3da57c80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
lib/gitlab/ci/config/node/stage.rb
lib/gitlab/ci/config/node/stage.rb
+1
-7
lib/gitlab/ci/config/node/validators.rb
lib/gitlab/ci/config/node/validators.rb
+9
-0
spec/lib/gitlab/ci/config/node/stage_spec.rb
spec/lib/gitlab/ci/config/node/stage_spec.rb
+4
-2
No files found.
lib/gitlab/ci/config/node/stage.rb
View file @
8baee987
...
...
@@ -10,13 +10,7 @@ module Gitlab
validations
do
validates
:config
,
key:
true
validate
do
|
entry
|
unless
entry
.
global
raise
Entry
::
InvalidError
,
'This entry needs reference to global configuration'
end
end
validates
:global
,
required_attribute:
true
end
def
self
.
default
...
...
lib/gitlab/ci/config/node/validators.rb
View file @
8baee987
...
...
@@ -33,6 +33,15 @@ module Gitlab
end
end
class
RequiredAttributeValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
if
value
.
nil?
raise
Entry
::
InvalidError
,
"Entry needs
#{
attribute
}
attribute set internally."
end
end
end
class
KeyValidator
<
ActiveModel
::
EachValidator
include
LegacyValidationHelpers
...
...
spec/lib/gitlab/ci/config/node/stage_spec.rb
View file @
8baee987
...
...
@@ -27,8 +27,10 @@ describe Gitlab::Ci::Config::Node::Stage do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
it
'raises error'
do
expect
{
entry
}
.
to
raise_error
Gitlab
::
Ci
::
Config
::
Node
::
Entry
::
InvalidError
expect
{
entry
}.
to
raise_error
(
Gitlab
::
Ci
::
Config
::
Node
::
Entry
::
InvalidError
,
/Entry needs global attribute set internally./
)
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