Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5456859b
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 搜索 >>
提交
5456859b
编写于
1月 09, 2017
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add method that checks for expiring build artifacts
上级
4a7e1423
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
17 deletion
+40
-17
app/models/ci/build.rb
app/models/ci/build.rb
+4
-0
app/views/projects/builds/_sidebar.html.haml
app/views/projects/builds/_sidebar.html.haml
+2
-2
spec/features/projects/builds_spec.rb
spec/features/projects/builds_spec.rb
+2
-2
spec/models/build_spec.rb
spec/models/build_spec.rb
+32
-13
未找到文件。
app/models/ci/build.rb
浏览文件 @
5456859b
...
...
@@ -507,6 +507,10 @@ module Ci
end
end
def
has_expiring_artifacts?
artifacts_expire_at
.
present?
end
def
keep_artifacts!
self
.
update
(
artifacts_expire_at:
nil
)
end
...
...
app/views/projects/builds/_sidebar.html.haml
浏览文件 @
5456859b
...
...
@@ -22,14 +22,14 @@
%p
.build-detail-row
The artifacts were removed
#{
time_ago_with_tooltip
(
@build
.
artifacts_expire_at
)
}
-
elsif
@build
.
artifacts_expire_at
-
elsif
@build
.
has_expiring_artifacts?
%p
.build-detail-row
The artifacts will be removed in
%span
.js-artifacts-remove
=
@build
.
artifacts_expire_at
-
if
@build
.
artifacts?
.btn-group.btn-group-justified
{
role: :group
}
-
if
@build
.
artifacts_expire_at
&&
can?
(
current_user
,
:update_build
,
@build
)
-
if
@build
.
has_expiring_artifacts?
&&
can?
(
current_user
,
:update_build
,
@build
)
=
link_to
keep_namespace_project_build_artifacts_path
(
@project
.
namespace
,
@project
,
@build
),
class:
'btn btn-sm btn-default'
,
method: :post
do
Keep
...
...
spec/features/projects/builds_spec.rb
浏览文件 @
5456859b
...
...
@@ -155,8 +155,8 @@ feature 'Builds', :feature do
click_link
'Keep'
expect
(
page
).
not_to
have
_link
'Keep'
expect
(
page
).
not_to
have
_content
'The artifacts will be removed'
expect
(
page
).
to
have_no
_link
'Keep'
expect
(
page
).
to
have_no
_content
'The artifacts will be removed'
end
end
...
...
spec/models/build_spec.rb
浏览文件 @
5456859b
...
...
@@ -652,6 +652,24 @@ describe Ci::Build, models: true do
end
end
describe
'#has_expiring_artifacts?'
do
context
'when artifacts have expiration date set'
do
before
{
build
.
update
(
artifacts_expire_at:
1
.
day
.
from_now
)
}
it
'has expiring artifacts'
do
expect
(
build
).
to
have_expiring_artifacts
end
end
context
'when artifacts do not have expiration date set'
do
before
{
build
.
update
(
artifacts_expire_at:
nil
)
}
it
'does not have expiring artifacts'
do
expect
(
build
).
not_to
have_expiring_artifacts
end
end
end
describe
'#artifacts_metadata?'
do
subject
{
build
.
artifacts_metadata?
}
context
'artifacts metadata does not exist'
do
...
...
@@ -663,19 +681,6 @@ describe Ci::Build, models: true do
it
{
is_expected
.
to
be_truthy
}
end
end
describe
'#repo_url'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:project
)
{
build
.
project
}
subject
{
build
.
repo_url
}
it
{
is_expected
.
to
be_a
(
String
)
}
it
{
is_expected
.
to
end_with
(
".git"
)
}
it
{
is_expected
.
to
start_with
(
project
.
web_url
[
0
..
6
])
}
it
{
is_expected
.
to
include
(
build
.
token
)
}
it
{
is_expected
.
to
include
(
'gitlab-ci-token'
)
}
it
{
is_expected
.
to
include
(
project
.
web_url
[
7
..-
1
])
}
end
describe
'#artifacts_expire_in'
do
subject
{
build
.
artifacts_expire_in
}
...
...
@@ -721,6 +726,20 @@ describe Ci::Build, models: true do
end
end
describe
'#repo_url'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:project
)
{
build
.
project
}
subject
{
build
.
repo_url
}
it
{
is_expected
.
to
be_a
(
String
)
}
it
{
is_expected
.
to
end_with
(
".git"
)
}
it
{
is_expected
.
to
start_with
(
project
.
web_url
[
0
..
6
])
}
it
{
is_expected
.
to
include
(
build
.
token
)
}
it
{
is_expected
.
to
include
(
'gitlab-ci-token'
)
}
it
{
is_expected
.
to
include
(
project
.
web_url
[
7
..-
1
])
}
end
describe
'#depends_on_builds'
do
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'build'
,
stage_idx:
0
,
stage:
'build'
)
}
let!
(
:rspec_test
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'rspec'
,
stage_idx:
1
,
stage:
'test'
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录