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
6dbd1c86
Commit
6dbd1c86
authored
Jun 06, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate new before script CI configuration entry
parent
251dd571
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
lib/gitlab/ci/config/node/before_script.rb
lib/gitlab/ci/config/node/before_script.rb
+3
-0
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+7
-5
spec/lib/gitlab/ci/config/node/before_script_spec.rb
spec/lib/gitlab/ci/config/node/before_script_spec.rb
+23
-1
No files found.
lib/gitlab/ci/config/node/before_script.rb
View file @
6dbd1c86
...
@@ -8,6 +8,9 @@ module Gitlab
...
@@ -8,6 +8,9 @@ module Gitlab
end
end
def
validate!
def
validate!
unless
validate_array_of_strings
(
@value
)
@errors
<<
'before_script should be an array of strings'
end
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
6dbd1c86
...
@@ -3,10 +3,12 @@ module Gitlab
...
@@ -3,10 +3,12 @@ module Gitlab
class
Config
class
Config
module
Node
module
Node
class
Entry
class
Entry
attr_reader
:hash
,
:config
,
:parent
,
:nodes
,
:erro
rs
include
Config
::
ValidationHelpe
rs
def
initialize
(
hash
,
config
,
parent
=
nil
)
attr_reader
:value
,
:config
,
:parent
,
:nodes
,
:errors
@hash
=
hash
def
initialize
(
value
,
config
,
parent
=
nil
)
@value
=
value
@config
=
config
@config
=
config
@parent
=
parent
@parent
=
parent
@nodes
=
{}
@nodes
=
{}
...
@@ -15,8 +17,8 @@ module Gitlab
...
@@ -15,8 +17,8 @@ module Gitlab
def
process!
def
process!
keys
.
each_pair
do
|
key
,
entry
|
keys
.
each_pair
do
|
key
,
entry
|
next
unless
hash
.
include?
(
key
)
next
unless
@value
.
include?
(
key
)
@nodes
[
key
]
=
entry
.
new
(
hash
[
key
],
config
,
self
)
@nodes
[
key
]
=
entry
.
new
(
@value
[
key
],
config
,
self
)
end
end
@nodes
.
values
.
each
(
&
:process!
)
@nodes
.
values
.
each
(
&
:process!
)
...
...
spec/lib/gitlab/ci/config/node/before_script_spec.rb
View file @
6dbd1c86
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
BeforeScript
do
describe
Gitlab
::
Ci
::
Config
::
Node
::
BeforeScript
do
let
(
:entry
)
{
described_class
.
new
(
hash
,
config
)
}
let
(
:entry
)
{
described_class
.
new
(
value
,
config
)
}
let
(
:config
)
{
double
(
'config'
)
}
describe
'#validate!'
do
before
{
entry
.
validate!
}
context
'when entry value is correct'
do
let
(
:value
)
{
[
'ls'
,
'pwd'
]
}
it
'does not append errors'
do
expect
(
entry
.
errors
).
to
be_empty
end
end
context
'when entry value is not correct'
do
let
(
:value
)
{
'ls'
}
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
/should be an array of strings/
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