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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d9d5042f
Commit
d9d5042f
authored
Jun 09, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract method that composes new Ci config entry
parent
33cd090b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
7 deletions
+32
-7
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+7
-3
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+25
-4
No files found.
lib/gitlab/ci/config/node/entry.rb
View file @
d9d5042f
...
...
@@ -20,14 +20,18 @@ module Gitlab
def
process!
return
if
leaf?
||
invalid?
keys
.
each
do
|
key
,
entry
|
add_node
(
key
,
entry
)
end
compose!
nodes
.
each
(
&
:process!
)
nodes
.
each
(
&
:validate!
)
end
def
compose!
keys
.
each
do
|
key
,
entry
|
add_node
(
key
,
entry
)
end
end
def
nodes
@nodes
.
values
end
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
d9d5042f
...
...
@@ -3,8 +3,6 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Global
do
let
(
:global
)
{
described_class
.
new
(
hash
)
}
before
{
global
.
process!
}
describe
'#keys'
do
it
'can contain global config keys'
do
expect
(
global
.
keys
).
to
include
:before_script
...
...
@@ -20,7 +18,18 @@ describe Gitlab::Ci::Config::Node::Global do
{
before_script:
[
'ls'
,
'pwd'
]
}
end
describe
'#compose!'
do
before
{
global
.
compose!
}
it
'instantiates entry nodes'
do
expect
(
global
.
nodes
.
first
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Script
end
end
describe
'#process!'
do
before
{
global
.
process!
}
it
'creates nodes hash'
do
expect
(
global
.
nodes
).
to
be_an
Array
end
...
...
@@ -48,13 +57,25 @@ describe Gitlab::Ci::Config::Node::Global do
end
describe
'#before_script'
do
context
'when processed'
do
before
{
global
.
process!
}
it
'returns correct script'
do
expect
(
global
.
before_script
).
to
eq
"ls
\n
pwd"
end
end
context
'when not processed'
do
it
'returns nil'
do
expect
(
global
.
before_script
).
to
be
nil
end
end
end
end
context
'when hash is not valid'
do
before
{
global
.
process!
}
let
(
:hash
)
do
{
before_script:
'ls'
}
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