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
iv
gitlab-ce
Commits
7c8f3b0c
Commit
7c8f3b0c
authored
Jun 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Duplicate CI config node factory on class level
parent
cc373a35
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
+41
-4
lib/gitlab/ci/config/node/configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+3
-1
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+3
-3
spec/lib/gitlab/ci/config/node/configurable_spec.rb
spec/lib/gitlab/ci/config/node/configurable_spec.rb
+35
-0
No files found.
lib/gitlab/ci/config/node/configurable.rb
View file @
7c8f3b0c
...
@@ -37,7 +37,9 @@ module Gitlab
...
@@ -37,7 +37,9 @@ module Gitlab
end
end
class_methods
do
class_methods
do
attr_reader
:allowed_nodes
def
allowed_nodes
Hash
[
@allowed_nodes
.
map
{
|
key
,
factory
|
[
key
,
factory
.
dup
]
}
]
end
private
private
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
7c8f3b0c
...
@@ -27,8 +27,8 @@ module Gitlab
...
@@ -27,8 +27,8 @@ module Gitlab
end
end
def
compose!
def
compose!
allowed_nodes
.
each
do
|
key
,
factory
|
allowed_nodes
.
each
do
|
key
,
essence
|
@nodes
[
key
]
=
create_node
(
key
,
factory
.
dup
)
@nodes
[
key
]
=
create_node
(
key
,
essence
)
end
end
end
end
...
@@ -62,7 +62,7 @@ module Gitlab
...
@@ -62,7 +62,7 @@ module Gitlab
private
private
def
create_node
(
key
,
factory
)
def
create_node
(
key
,
essence
)
raise
NotImplementedError
raise
NotImplementedError
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/configurable_spec.rb
0 → 100644
View file @
7c8f3b0c
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Configurable
do
let
(
:node
)
{
Class
.
new
}
before
do
node
.
include
(
described_class
)
end
describe
'allowed nodes'
do
before
do
node
.
class_eval
do
allow_node
:object
,
Object
,
description:
'test object'
end
end
describe
'#allowed_nodes'
do
it
'has valid allowed nodes'
do
expect
(
node
.
allowed_nodes
).
to
include
:object
end
it
'creates a node factory'
do
expect
(
node
.
allowed_nodes
[
:object
])
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Factory
end
it
'returns a duplicated factory object'
do
first_factory
=
node
.
allowed_nodes
[
:object
]
second_factory
=
node
.
allowed_nodes
[
:object
]
expect
(
first_factory
).
not_to
be_equal
(
second_factory
)
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