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
Tatuya Kamada
gitlab-ce
Commits
c91298d5
Commit
c91298d5
authored
Jun 21, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use generic type validator in new ci configuration
parent
9510d31b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
lib/gitlab/ci/config/node/configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+1
-1
lib/gitlab/ci/config/node/validators.rb
lib/gitlab/ci/config/node/validators.rb
+6
-3
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+6
-0
No files found.
lib/gitlab/ci/config/node/configurable.rb
View file @
c91298d5
...
@@ -19,7 +19,7 @@ module Gitlab
...
@@ -19,7 +19,7 @@ module Gitlab
included
do
included
do
validations
do
validations
do
validates
:config
,
hash:
true
validates
:config
,
type:
Hash
end
end
end
end
...
...
lib/gitlab/ci/config/node/validators.rb
View file @
c91298d5
...
@@ -13,10 +13,13 @@ module Gitlab
...
@@ -13,10 +13,13 @@ module Gitlab
end
end
end
end
class
Hash
Validator
<
ActiveModel
::
EachValidator
class
Type
Validator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
def
validate_each
(
record
,
attribute
,
value
)
unless
value
.
is_a?
(
Hash
)
type
=
options
[
:with
]
record
.
errors
.
add
(
attribute
,
'should be a configuration entry hash'
)
raise
unless
type
.
is_a?
(
Class
)
unless
value
.
is_a?
(
type
)
record
.
errors
.
add
(
attribute
,
"should be a
#{
type
.
name
}
"
)
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
c91298d5
...
@@ -106,5 +106,11 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -106,5 +106,11 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
).
not_to
be_valid
expect
(
global
).
not_to
be_valid
end
end
end
end
describe
'#errors'
do
it
'returns error about invalid type'
do
expect
(
global
.
errors
.
first
).
to
match
/should be a hash/
end
end
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