BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e017e1b6
Commit
e017e1b6
authored
Jun 24, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ci config class that represents a boolean value
parent
04ece666
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
0 deletions
+62
-0
boolean.rb
lib/gitlab/ci/config/node/boolean.rb
+18
-0
validators.rb
lib/gitlab/ci/config/node/validators.rb
+10
-0
boolean_spec.rb
spec/lib/gitlab/ci/config/node/boolean_spec.rb
+34
-0
No files found.
lib/gitlab/ci/config/node/boolean.rb
0 → 100644
View file @
e017e1b6
module
Gitlab
module
Ci
class
Config
module
Node
##
# Entry that represents a boolean value.
#
class
Boolean
<
Entry
include
Validatable
validations
do
validates
:config
,
boolean:
true
end
end
end
end
end
end
lib/gitlab/ci/config/node/validators.rb
View file @
e017e1b6
...
...
@@ -13,6 +13,16 @@ module Gitlab
end
end
class
BooleanValidator
<
ActiveModel
::
EachValidator
include
LegacyValidationHelpers
def
validate_each
(
record
,
attribute
,
value
)
unless
validate_boolean
(
value
)
record
.
errors
.
add
(
attribute
,
'should be a boolean value'
)
end
end
end
class
KeyValidator
<
ActiveModel
::
EachValidator
include
LegacyValidationHelpers
...
...
spec/lib/gitlab/ci/config/node/boolean_spec.rb
0 → 100644
View file @
e017e1b6
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Boolean
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
context
'when entry config value is valid'
do
let
(
:config
)
{
false
}
describe
'#value'
do
it
'returns key value'
do
expect
(
entry
.
value
).
to
eq
false
end
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
end
context
'when entry value is not valid'
do
let
(
:config
)
{
[
'incorrect'
]
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'Boolean config should be a boolean value'
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