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
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
+30
-5
entry.rb
lib/gitlab/ci/config/node/entry.rb
+7
-3
global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+23
-2
No files found.
lib/gitlab/ci/config/node/entry.rb
View file @
d9d5042f
...
@@ -20,14 +20,18 @@ module Gitlab
...
@@ -20,14 +20,18 @@ module Gitlab
def
process!
def
process!
return
if
leaf?
||
invalid?
return
if
leaf?
||
invalid?
keys
.
each
do
|
key
,
entry
|
compose!
add_node
(
key
,
entry
)
end
nodes
.
each
(
&
:process!
)
nodes
.
each
(
&
:process!
)
nodes
.
each
(
&
:validate!
)
nodes
.
each
(
&
:validate!
)
end
end
def
compose!
keys
.
each
do
|
key
,
entry
|
add_node
(
key
,
entry
)
end
end
def
nodes
def
nodes
@nodes
.
values
@nodes
.
values
end
end
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
d9d5042f
...
@@ -3,8 +3,6 @@ require 'spec_helper'
...
@@ -3,8 +3,6 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Global
do
describe
Gitlab
::
Ci
::
Config
::
Node
::
Global
do
let
(
:global
)
{
described_class
.
new
(
hash
)
}
let
(
:global
)
{
described_class
.
new
(
hash
)
}
before
{
global
.
process!
}
describe
'#keys'
do
describe
'#keys'
do
it
'can contain global config keys'
do
it
'can contain global config keys'
do
expect
(
global
.
keys
).
to
include
:before_script
expect
(
global
.
keys
).
to
include
:before_script
...
@@ -20,7 +18,18 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -20,7 +18,18 @@ describe Gitlab::Ci::Config::Node::Global do
{
before_script:
[
'ls'
,
'pwd'
]
}
{
before_script:
[
'ls'
,
'pwd'
]
}
end
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
describe
'#process!'
do
before
{
global
.
process!
}
it
'creates nodes hash'
do
it
'creates nodes hash'
do
expect
(
global
.
nodes
).
to
be_an
Array
expect
(
global
.
nodes
).
to
be_an
Array
end
end
...
@@ -48,13 +57,25 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -48,13 +57,25 @@ describe Gitlab::Ci::Config::Node::Global do
end
end
describe
'#before_script'
do
describe
'#before_script'
do
context
'when processed'
do
before
{
global
.
process!
}
it
'returns correct script'
do
it
'returns correct script'
do
expect
(
global
.
before_script
).
to
eq
"ls
\n
pwd"
expect
(
global
.
before_script
).
to
eq
"ls
\n
pwd"
end
end
end
end
context
'when not processed'
do
it
'returns nil'
do
expect
(
global
.
before_script
).
to
be
nil
end
end
end
end
end
context
'when hash is not valid'
do
context
'when hash is not valid'
do
before
{
global
.
process!
}
let
(
:hash
)
do
let
(
:hash
)
do
{
before_script:
'ls'
}
{
before_script:
'ls'
}
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