Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
07f7a01b
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,体验更适合开发者的 AI 搜索 >>
提交
07f7a01b
编写于
8月 31, 2017
作者:
S
Shinya Maeda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve spec. Add validation for accel_level on runner.
上级
d3bf0160
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
54 addition
and
33 deletion
+54
-33
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-0
spec/factories/ci/runners.rb
spec/factories/ci/runners.rb
+2
-2
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+17
-5
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+30
-24
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+4
-2
未找到文件。
app/models/ci/runner.rb
浏览文件 @
07f7a01b
...
@@ -35,6 +35,7 @@ module Ci
...
@@ -35,6 +35,7 @@ module Ci
end
end
validate
:tag_constraints
validate
:tag_constraints
validates
:access_level
,
presence:
true
acts_as_taggable
acts_as_taggable
...
...
spec/factories/ci/runners.rb
浏览文件 @
07f7a01b
...
@@ -23,11 +23,11 @@ FactoryGirl.define do
...
@@ -23,11 +23,11 @@ FactoryGirl.define do
end
end
trait
:ref_protected
do
trait
:ref_protected
do
access_level
'ref_protected'
access_level
:ref_protected
end
end
trait
:not_protected
do
trait
:not_protected
do
access_level
'not_protected'
access_level
:not_protected
end
end
end
end
end
end
spec/models/ci/build_spec.rb
浏览文件 @
07f7a01b
...
@@ -44,13 +44,25 @@ describe Ci::Build do
...
@@ -44,13 +44,25 @@ describe Ci::Build do
end
end
describe
'.ref_protected'
do
describe
'.ref_protected'
do
let!
(
:protected_job
)
{
create
(
:ci_build
,
:protected
)
}
let!
(
:unprotected_job
)
{
create
(
:ci_build
,
:unprotected
)
}
subject
{
described_class
.
ref_protected
}
subject
{
described_class
.
ref_protected
}
it
{
is_expected
.
to
include
(
protected_job
)
}
context
'when protected is true'
do
it
{
is_expected
.
not_to
include
(
unprotected_job
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:protected
)
}
it
{
is_expected
.
to
include
(
job
)
}
end
context
'when protected is false'
do
let!
(
:job
)
{
create
(
:ci_build
,
:unprotected
)
}
it
{
is_expected
.
not_to
include
(
job
)
}
end
context
'when protected is false'
do
let!
(
:job
)
{
create
(
:ci_build
,
protected:
nil
)
}
it
{
is_expected
.
not_to
include
(
job
)
}
end
end
end
describe
'#actionize'
do
describe
'#actionize'
do
...
...
spec/models/ci/runner_spec.rb
浏览文件 @
07f7a01b
...
@@ -2,6 +2,8 @@ require 'spec_helper'
...
@@ -2,6 +2,8 @@ require 'spec_helper'
describe
Ci
::
Runner
do
describe
Ci
::
Runner
do
describe
'validation'
do
describe
'validation'
do
it
{
is_expected
.
to
validate_presence_of
(
:access_level
)
}
context
'when runner is not allowed to pick untagged jobs'
do
context
'when runner is not allowed to pick untagged jobs'
do
context
'when runner does not have tags'
do
context
'when runner does not have tags'
do
it
'is not valid'
do
it
'is not valid'
do
...
@@ -19,6 +21,34 @@ describe Ci::Runner do
...
@@ -19,6 +21,34 @@ describe Ci::Runner do
end
end
end
end
describe
'#access_level'
do
context
'when creating new runner and access_level is nil'
do
let
(
:runner
)
do
build
(
:ci_runner
,
access_level:
nil
)
end
it
"object is invalid"
do
expect
(
runner
).
not_to
be_valid
end
end
context
'when creating new runner and access_level is defined in enum'
do
let
(
:runner
)
do
build
(
:ci_runner
,
access_level: :not_protected
)
end
it
"object is valid"
do
expect
(
runner
).
to
be_valid
end
end
context
'when creating new runner and access_level is not defined in enum'
do
it
"raises an error"
do
expect
{
build
(
:ci_runner
,
access_level: :this_is_not_defined
)
}.
to
raise_error
(
ArgumentError
)
end
end
end
describe
'#display_name'
do
describe
'#display_name'
do
it
'returns the description if it has a value'
do
it
'returns the description if it has a value'
do
runner
=
FactoryGirl
.
build
(
:ci_runner
,
description:
'Linux/Ruby-1.9.3-p448'
)
runner
=
FactoryGirl
.
build
(
:ci_runner
,
description:
'Linux/Ruby-1.9.3-p448'
)
...
@@ -480,28 +510,4 @@ describe Ci::Runner do
...
@@ -480,28 +510,4 @@ describe Ci::Runner do
expect
(
described_class
.
search
(
runner
.
description
.
upcase
)).
to
eq
([
runner
])
expect
(
described_class
.
search
(
runner
.
description
.
upcase
)).
to
eq
([
runner
])
end
end
end
end
describe
'.access_level'
do
context
'when access_level of a runner is ref_protected'
do
before
do
create
(
:ci_runner
,
:ref_protected
)
end
it
'a protected runner exists'
do
expect
(
described_class
.
count
).
to
eq
(
1
)
expect
(
described_class
.
last
.
ref_protected?
).
to
eq
(
true
)
end
end
context
'when access_level of a runner is not_protected'
do
before
do
create
(
:ci_runner
,
:not_protected
)
end
it
'an not_protected runner exists'
do
expect
(
described_class
.
count
).
to
eq
(
1
)
expect
(
described_class
.
last
.
not_protected?
).
to
eq
(
true
)
end
end
end
end
end
spec/services/ci/register_job_service_spec.rb
浏览文件 @
07f7a01b
...
@@ -215,7 +215,9 @@ module Ci
...
@@ -215,7 +215,9 @@ module Ci
end
end
end
end
context
'when a runner is not_protected'
do
context
'when access_level of runner is not_protected'
do
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:not_protected
,
:specific
)
}
context
'when a job is protected'
do
context
'when a job is protected'
do
let!
(
:pending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
let!
(
:pending_build
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
...
@@ -233,7 +235,7 @@ module Ci
...
@@ -233,7 +235,7 @@ module Ci
end
end
end
end
context
'when a runner is ref_protected'
do
context
'when a
ccess_level of
runner is ref_protected'
do
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:ref_protected
,
:specific
)
}
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:ref_protected
,
:specific
)
}
context
'when a job is protected'
do
context
'when a job is protected'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录