Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
700078e8
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
700078e8
编写于
8月 06, 2016
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename unspecified and undefined CI config nodes
上级
6c704fd9
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
103 addition
and
64 deletion
+103
-64
lib/gitlab/ci/config/node/factory.rb
lib/gitlab/ci/config/node/factory.rb
+4
-4
lib/gitlab/ci/config/node/undefined.rb
lib/gitlab/ci/config/node/undefined.rb
+23
-4
lib/gitlab/ci/config/node/unspecified.rb
lib/gitlab/ci/config/node/unspecified.rb
+19
-0
spec/lib/gitlab/ci/config/node/factory_spec.rb
spec/lib/gitlab/ci/config/node/factory_spec.rb
+2
-1
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+2
-2
spec/lib/gitlab/ci/config/node/null_spec.rb
spec/lib/gitlab/ci/config/node/null_spec.rb
+0
-41
spec/lib/gitlab/ci/config/node/undefined_spec.rb
spec/lib/gitlab/ci/config/node/undefined_spec.rb
+21
-12
spec/lib/gitlab/ci/config/node/unspecified_spec.rb
spec/lib/gitlab/ci/config/node/unspecified_spec.rb
+32
-0
未找到文件。
lib/gitlab/ci/config/node/factory.rb
浏览文件 @
700078e8
...
...
@@ -37,8 +37,8 @@ module Gitlab
# See issue #18775.
#
if
@value
.
nil?
Node
::
Un
defin
ed
.
new
(
fabricate_un
defin
ed
Node
::
Un
specifi
ed
.
new
(
fabricate_un
specifi
ed
)
else
fabricate
(
@node
,
@value
)
...
...
@@ -47,13 +47,13 @@ module Gitlab
private
def
fabricate_un
defin
ed
def
fabricate_un
specifi
ed
##
# If node has a default value we fabricate concrete node
# with default value.
#
if
@node
.
default
.
nil?
fabricate
(
Node
::
Null
)
fabricate
(
Node
::
Undefined
)
else
fabricate
(
@node
,
@node
.
default
)
end
...
...
lib/gitlab/ci/config/node/undefined.rb
浏览文件 @
700078e8
...
...
@@ -3,15 +3,34 @@ module Gitlab
class
Config
module
Node
##
# This class represents an un
specified entry
node.
# This class represents an un
defined
node.
#
# It decorates original entry adding method that indicates it is
# unspecified.
# Implements the Null Object pattern.
#
class
Undefined
<
SimpleDelegator
class
Undefined
<
Entry
def
initialize
(
*
)
super
(
nil
)
end
def
value
nil
end
def
valid?
true
end
def
errors
[]
end
def
specified?
false
end
def
relevant?
false
end
end
end
end
...
...
lib/gitlab/ci/config/node/
null
.rb
→
lib/gitlab/ci/config/node/
unspecified
.rb
浏览文件 @
700078e8
...
...
@@ -3,30 +3,15 @@ module Gitlab
class
Config
module
Node
##
# This class represents an un
defined
node.
# This class represents an un
specified entry
node.
#
# Implements the Null Object pattern.
# It decorates original entry adding method that indicates it is
# unspecified.
#
class
Null
<
Entry
def
value
nil
end
def
valid?
true
end
def
errors
[]
end
class
Unspecified
<
SimpleDelegator
def
specified?
false
end
def
relevant?
false
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/factory_spec.rb
浏览文件 @
700078e8
...
...
@@ -65,7 +65,8 @@ describe Gitlab::Ci::Config::Node::Factory do
.
value
(
nil
)
.
create!
expect
(
entry
).
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Undefined
expect
(
entry
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Unspecified
end
end
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
浏览文件 @
700078e8
...
...
@@ -156,9 +156,9 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
.
descendants
.
count
).
to
eq
8
end
it
'contains un
defin
ed nodes'
do
it
'contains un
specifi
ed nodes'
do
expect
(
global
.
descendants
.
first
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Un
defin
ed
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Un
specifi
ed
end
end
...
...
spec/lib/gitlab/ci/config/node/null_spec.rb
已删除
100644 → 0
浏览文件 @
6c704fd9
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Null
do
let
(
:null
)
{
described_class
.
new
(
nil
)
}
describe
'#leaf?'
do
it
'is leaf node'
do
expect
(
null
).
to
be_leaf
end
end
describe
'#valid?'
do
it
'is always valid'
do
expect
(
null
).
to
be_valid
end
end
describe
'#errors'
do
it
'is does not contain errors'
do
expect
(
null
.
errors
).
to
be_empty
end
end
describe
'#value'
do
it
'returns nil'
do
expect
(
null
.
value
).
to
eq
nil
end
end
describe
'#relevant?'
do
it
'is not relevant'
do
expect
(
null
.
relevant?
).
to
eq
false
end
end
describe
'#specified?'
do
it
'is not defined'
do
expect
(
null
.
specified?
).
to
eq
false
end
end
end
spec/lib/gitlab/ci/config/node/undefined_spec.rb
浏览文件 @
700078e8
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Undefined
do
let
(
:undefined
)
{
described_class
.
new
(
entry
)
}
let
(
:entry
)
{
spy
(
'Entry'
)
}
let
(
:entry
)
{
described_class
.
new
}
describe
'#leaf?'
do
it
'is leaf node'
do
expect
(
entry
).
to
be_leaf
end
end
describe
'#valid?'
do
it
'
delegates method to entry
'
do
expect
(
undefined
.
valid
).
to
eq
entry
it
'
is always valid
'
do
expect
(
entry
).
to
be_valid
end
end
describe
'#errors'
do
it
'
delegates method to entry
'
do
expect
(
undefined
.
errors
).
to
eq
entr
y
it
'
is does not contain errors
'
do
expect
(
entry
.
errors
).
to
be_empt
y
end
end
describe
'#value'
do
it
'
delegates method to entry
'
do
expect
(
undefined
.
value
).
to
eq
entry
it
'
returns nil
'
do
expect
(
entry
.
value
).
to
eq
nil
end
end
describe
'#specified?'
do
it
'is always false'
do
allow
(
entry
).
to
receive
(
:specified?
).
and_return
(
true
)
describe
'#relevant?'
do
it
'is not relevant'
do
expect
(
entry
.
relevant?
).
to
eq
false
end
end
expect
(
undefined
.
specified?
).
to
be
false
describe
'#specified?'
do
it
'is not defined'
do
expect
(
entry
.
specified?
).
to
eq
false
end
end
end
spec/lib/gitlab/ci/config/node/unspecified_spec.rb
0 → 100644
浏览文件 @
700078e8
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Unspecified
do
let
(
:unspecified
)
{
described_class
.
new
(
entry
)
}
let
(
:entry
)
{
spy
(
'Entry'
)
}
describe
'#valid?'
do
it
'delegates method to entry'
do
expect
(
unspecified
.
valid?
).
to
eq
entry
end
end
describe
'#errors'
do
it
'delegates method to entry'
do
expect
(
unspecified
.
errors
).
to
eq
entry
end
end
describe
'#value'
do
it
'delegates method to entry'
do
expect
(
unspecified
.
value
).
to
eq
entry
end
end
describe
'#specified?'
do
it
'is always false'
do
allow
(
entry
).
to
receive
(
:specified?
).
and_return
(
true
)
expect
(
unspecified
.
specified?
).
to
be
false
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录