Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b5f6a5f9
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,发现更多精彩内容 >>
提交
b5f6a5f9
编写于
12月 08, 2017
作者:
K
Kamil Trzcinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Chain::Command specs
上级
865341ac
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
190 addition
and
10 deletion
+190
-10
lib/gitlab/ci/pipeline/chain/command.rb
lib/gitlab/ci/pipeline/chain/command.rb
+1
-1
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
+185
-0
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
+1
-1
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+3
-8
未找到文件。
lib/gitlab/ci/pipeline/chain/command.rb
浏览文件 @
b5f6a5f9
...
...
@@ -46,7 +46,7 @@ module Gitlab
end
def
before_sha
before_sha
||
checkout_sha
||
Gitlab
::
Git
::
BLANK_SHA
self
[
:before_sha
]
||
checkout_sha
||
Gitlab
::
Git
::
BLANK_SHA
end
def
protected_ref?
...
...
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
0 → 100644
浏览文件 @
b5f6a5f9
require
'spec_helper'
describe
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Command
do
set
(
:project
)
{
create
(
:project
,
:repository
)
}
describe
'#initialize'
do
subject
do
described_class
.
new
(
origin_ref:
'master'
)
end
it
'properly initialises object from hash'
do
expect
(
subject
.
origin_ref
).
to
eq
(
'master'
)
end
end
context
'handling of origin_ref'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
origin_ref:
origin_ref
)
}
describe
'#branch_exists?'
do
subject
{
command
.
branch_exists?
}
context
'for existing branch'
do
let
(
:origin_ref
)
{
'master'
}
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'for invalid branch'
do
let
(
:origin_ref
)
{
'something'
}
it
{
is_expected
.
to
eq
(
false
)
}
end
end
describe
'#tag_exists?'
do
subject
{
command
.
tag_exists?
}
context
'for existing ref'
do
let
(
:origin_ref
)
{
'v1.0.0'
}
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'for invalid ref'
do
let
(
:origin_ref
)
{
'something'
}
it
{
is_expected
.
to
eq
(
false
)
}
end
end
describe
'#ref'
do
subject
{
command
.
ref
}
context
'for regular ref'
do
let
(
:origin_ref
)
{
'master'
}
it
{
is_expected
.
to
eq
(
'master'
)
}
end
context
'for branch ref'
do
let
(
:origin_ref
)
{
'refs/heads/master'
}
it
{
is_expected
.
to
eq
(
'master'
)
}
end
context
'for tag ref'
do
let
(
:origin_ref
)
{
'refs/tags/1.0.0'
}
it
{
is_expected
.
to
eq
(
'1.0.0'
)
}
end
context
'for other refs'
do
let
(
:origin_ref
)
{
'refs/merge-requests/11/head'
}
it
{
is_expected
.
to
eq
(
'refs/merge-requests/11/head'
)
}
end
end
end
describe
'#sha'
do
subject
{
command
.
sha
}
context
'when invalid checkout_sha is specified'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
checkout_sha:
'aaa'
)
}
it
'returns empty value'
do
is_expected
.
to
be_nil
end
end
context
'when a valid checkout_sha is specified'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
checkout_sha:
project
.
commit
.
id
)
}
it
'returns checkout_sha'
do
is_expected
.
to
eq
(
project
.
commit
.
id
)
end
end
context
'when a valid after_sha is specified'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
after_sha:
project
.
commit
.
id
)
}
it
'returns after_sha'
do
is_expected
.
to
eq
(
project
.
commit
.
id
)
end
end
context
'when a valid origin_ref is specified'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
origin_ref:
'HEAD'
)
}
it
'returns SHA for given ref'
do
is_expected
.
to
eq
(
project
.
commit
.
id
)
end
end
end
describe
'#origin_sha'
do
subject
{
command
.
origin_sha
}
context
'when using checkout_sha and after_sha'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
checkout_sha:
'aaa'
,
after_sha:
'bbb'
)
}
it
'uses checkout_sha'
do
is_expected
.
to
eq
(
'aaa'
)
end
end
context
'when using after_sha only'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
after_sha:
'bbb'
)
}
it
'uses after_sha'
do
is_expected
.
to
eq
(
'bbb'
)
end
end
end
describe
'#before_sha'
do
subject
{
command
.
before_sha
}
context
'when using checkout_sha and before_sha'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
checkout_sha:
'aaa'
,
before_sha:
'bbb'
)
}
it
'uses before_sha'
do
is_expected
.
to
eq
(
'bbb'
)
end
end
context
'when using checkout_sha only'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
checkout_sha:
'aaa'
)
}
it
'uses checkout_sha'
do
is_expected
.
to
eq
(
'aaa'
)
end
end
context
'when checkout_sha and before_sha are empty'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
)
}
it
'uses BLANK_SHA'
do
is_expected
.
to
eq
(
Gitlab
::
Git
::
BLANK_SHA
)
end
end
end
describe
'#protected_ref?'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
origin_ref:
'my-branch'
)
}
subject
{
command
.
protected_ref?
}
context
'when a ref is protected'
do
before
do
expect_any_instance_of
(
Project
).
to
receive
(
:protected_for?
).
with
(
'my-branch'
).
and_return
(
true
)
end
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'when a ref is unprotected'
do
before
do
expect_any_instance_of
(
Project
).
to
receive
(
:protected_for?
).
with
(
'my-branch'
).
and_return
(
false
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
end
end
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
浏览文件 @
b5f6a5f9
...
...
@@ -12,7 +12,7 @@ describe Gitlab::Ci::Pipeline::Chain::Create do
let
(
:command
)
do
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Command
.
new
(
project:
project
,
current_user:
user
,
seeds_block:
nil
)
current_user:
user
,
seeds_block:
nil
)
end
let
(
:step
)
{
described_class
.
new
(
pipeline
,
command
)
}
...
...
spec/services/ci/create_pipeline_service_spec.rb
浏览文件 @
b5f6a5f9
...
...
@@ -519,13 +519,8 @@ describe Ci::CreatePipelineService do
end
end
context
'when pipelie is running for a tag'
do
context
'when pipeli
n
e is running for a tag'
do
before
do
allow_any_instance_of
(
Repository
)
.
to
receive
(
:tag_exists?
).
and_return
(
false
)
allow_any_instance_of
(
Repository
)
.
to
receive
(
:tag_exists?
).
with
(
'refs/tags/mytag'
).
and_return
(
true
)
config
=
YAML
.
dump
(
test:
{
script:
'test'
,
only:
[
'branches'
]
},
deploy:
{
script:
'deploy'
,
only:
[
'tags'
]
})
...
...
@@ -533,7 +528,7 @@ describe Ci::CreatePipelineService do
end
it
'creates a tagged pipeline'
do
pipeline
=
execute_service
(
ref:
'
mytag
'
)
pipeline
=
execute_service
(
ref:
'
v1.0.0
'
)
expect
(
pipeline
.
tag?
).
to
be
true
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录