Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
f494f271
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 搜索 >>
提交
f494f271
编写于
5月 16, 2018
作者:
M
Mayra Cabrera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Respect the inheritance chain between Ci::Build and CommitStatus
Also moves the assertions were they belong
上级
86ef8221
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
48 addition
and
31 deletion
+48
-31
app/presenters/ci/build_presenter.rb
app/presenters/ci/build_presenter.rb
+1
-24
app/presenters/commit_status_presenter.rb
app/presenters/commit_status_presenter.rb
+23
-1
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+2
-5
spec/models/generic_commit_status_spec.rb
spec/models/generic_commit_status_spec.rb
+6
-0
spec/presenters/ci/build_presenter_spec.rb
spec/presenters/ci/build_presenter_spec.rb
+1
-1
spec/presenters/commit_status_presenter_spec.rb
spec/presenters/commit_status_presenter_spec.rb
+15
-0
未找到文件。
app/presenters/ci/build_presenter.rb
浏览文件 @
f494f271
module
Ci
class
BuildPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
CALLOUT_FAILURE_MESSAGES
=
{
unknown_failure:
'There is an unknown failure, please try again'
,
script_failure:
'There has been a script failure. Check the job log for more information'
,
api_failure:
'There has been an API failure, please try again'
,
stuck_or_timeout_failure:
'There has been a timeout failure or the job got stuck. Check your timeout limits or try again'
,
runner_system_failure:
'There has been a runner system failure, please try again'
,
missing_dependency_failure:
'There has been a missing dependency failure, check the job log for more information'
}.
freeze
presents
:build
class
BuildPresenter
<
CommitStatusPresenter
def
erased_by_user?
# Build can be erased through API, therefore it does not have
# `erased_by` user assigned in that case.
...
...
@@ -44,14 +33,6 @@ module Ci
"
#{
subject
.
name
}
-
#{
detailed_status
.
status_tooltip
}
"
end
def
callout_failure_message
CALLOUT_FAILURE_MESSAGES
[
failure_reason
.
to_sym
]
end
def
recoverable?
failed?
&&
!
unrecoverable?
end
private
def
tooltip_for_badge
...
...
@@ -61,9 +42,5 @@ module Ci
def
detailed_status
@detailed_status
||=
subject
.
detailed_status
(
user
)
end
def
unrecoverable?
script_failure?
||
missing_dependency_failure?
end
end
end
app/presenters/commit_status_presenter.rb
浏览文件 @
f494f271
class
CommitStatusPresenter
<
Ci
::
BuildPresenter
class
CommitStatusPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
CALLOUT_FAILURE_MESSAGES
=
{
unknown_failure:
'There is an unknown failure, please try again'
,
script_failure:
'There has been a script failure. Check the job log for more information'
,
api_failure:
'There has been an API failure, please try again'
,
stuck_or_timeout_failure:
'There has been a timeout failure or the job got stuck. Check your timeout limits or try again'
,
runner_system_failure:
'There has been a runner system failure, please try again'
,
missing_dependency_failure:
'There has been a missing dependency failure, check the job log for more information'
}.
freeze
presents
:build
def
callout_failure_message
CALLOUT_FAILURE_MESSAGES
[
failure_reason
.
to_sym
]
end
def
recoverable?
failed?
&&
!
unrecoverable?
end
def
unrecoverable?
script_failure?
||
missing_dependency_failure?
end
end
spec/models/commit_status_spec.rb
浏览文件 @
f494f271
...
...
@@ -567,11 +567,8 @@ describe CommitStatus do
end
describe
'#present'
do
let
(
:generic_commit_status
)
{
create
(
:generic_commit_status
)
}
subject
{
commit_status
.
present
}
it
'returns a presenter'
do
expect
(
commit_status
.
present
).
to
be_a
(
Ci
::
BuildPresenter
)
expect
(
generic_commit_status
.
present
).
to
be_a
(
Ci
::
BuildPresenter
)
end
it
{
is_expected
.
to
be_a
(
CommitStatusPresenter
)
}
end
end
spec/models/generic_commit_status_spec.rb
浏览文件 @
f494f271
...
...
@@ -78,4 +78,10 @@ describe GenericCommitStatus do
it
{
is_expected
.
not_to
be_nil
}
end
end
describe
'#present'
do
subject
{
generic_commit_status
.
present
}
it
{
is_expected
.
to
be_a
(
GenericCommitStatusPresenter
)
}
end
end
spec/presenters/ci/build_presenter_spec.rb
浏览文件 @
f494f271
...
...
@@ -10,7 +10,7 @@ describe Ci::BuildPresenter do
end
it
'inherits from Gitlab::View::Presenter::Delegated'
do
expect
(
described_class
.
superclass
).
to
eq
(
Gitlab
::
View
::
Presenter
::
Delegated
)
expect
(
described_class
.
ancestors
).
to
include
(
Gitlab
::
View
::
Presenter
::
Delegated
)
end
describe
'#initialize'
do
...
...
spec/presenters/commit_status_presenter_spec.rb
0 → 100644
浏览文件 @
f494f271
require
'spec_helper'
describe
CommitStatusPresenter
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
subject
(
:presenter
)
do
described_class
.
new
(
build
)
end
it
'inherits from Gitlab::View::Presenter::Delegated'
do
expect
(
described_class
.
superclass
).
to
eq
(
Gitlab
::
View
::
Presenter
::
Delegated
)
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录