Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
e79b867d
提交
e79b867d
编辑于
9 years ago
作者:
Rémy Coutable
浏览文件
操作
下载
补丁
差异文件
Ensure empty recipients are rejected in BuildsEmailService
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
上级
1749bd3b
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
3
隐藏空白变更内容
行内
左右并排
显示
3 个更改的文件
CHANGELOG
+1
-0
1 个添加, 0 个删除
CHANGELOG
app/models/project_services/builds_email_service.rb
+7
-4
7 个添加, 4 个删除
app/models/project_services/builds_email_service.rb
spec/models/project_services/builds_email_service_spec.rb
+22
-2
22 个添加, 2 个删除
spec/models/project_services/builds_email_service_spec.rb
有
30 个添加
和
6 个删除
CHANGELOG
+
1
−
0
浏览文件 @
e79b867d
...
@@ -14,6 +14,7 @@ v 8.7.0 (unreleased)
...
@@ -14,6 +14,7 @@ v 8.7.0 (unreleased)
- Add links to CI setup documentation from project settings and builds pages
- Add links to CI setup documentation from project settings and builds pages
- Handle nil descriptions in Slack issue messages (Stan Hu)
- Handle nil descriptions in Slack issue messages (Stan Hu)
- Add default scope to projects to exclude projects pending deletion
- Add default scope to projects to exclude projects pending deletion
- Ensure empty recipients are rejected in BuildsEmailService
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
...
...
此差异已折叠。
点击以展开。
app/models/project_services/builds_email_service.rb
+
7
−
4
浏览文件 @
e79b867d
...
@@ -50,12 +50,15 @@ def supported_events
...
@@ -50,12 +50,15 @@ def supported_events
def
execute
(
push_data
)
def
execute
(
push_data
)
return
unless
supported_events
.
include?
(
push_data
[
:object_kind
])
return
unless
supported_events
.
include?
(
push_data
[
:object_kind
])
return
unless
should_build_be_notified?
(
push_data
)
if
should_build_be_notified?
(
push_data
)
recipients
=
all_recipients
(
push_data
)
if
recipients
.
any?
BuildEmailWorker
.
perform_async
(
BuildEmailWorker
.
perform_async
(
push_data
[
:build_id
],
push_data
[
:build_id
],
all_
recipients
(
push_data
)
,
recipients
,
push_data
,
push_data
)
)
end
end
end
end
...
@@ -84,7 +87,7 @@ def allow_failure?(data)
...
@@ -84,7 +87,7 @@ def allow_failure?(data)
end
end
def
all_recipients
(
data
)
def
all_recipients
(
data
)
all_recipients
=
recipients
.
split
(
','
)
all_recipients
=
recipients
.
split
(
','
)
.
compact
.
reject
(
&
:blank?
)
if
add_pusher?
&&
data
[
:user
][
:email
]
if
add_pusher?
&&
data
[
:user
][
:email
]
all_recipients
<<
"
#{
data
[
:user
][
:email
]
}
"
all_recipients
<<
"
#{
data
[
:user
][
:email
]
}
"
...
...
此差异已折叠。
点击以展开。
spec/models/project_services/builds_email_service_spec.rb
+
22
−
2
浏览文件 @
e79b867d
...
@@ -6,18 +6,38 @@
...
@@ -6,18 +6,38 @@
let
(
:service
)
{
BuildsEmailService
.
new
}
let
(
:service
)
{
BuildsEmailService
.
new
}
describe
:execute
do
describe
:execute
do
it
"
sends email
"
do
it
'
sends email
'
do
service
.
recipients
=
'test@gitlab.com'
service
.
recipients
=
'test@gitlab.com'
data
[
:build_status
]
=
'failed'
data
[
:build_status
]
=
'failed'
expect
(
BuildEmailWorker
).
to
receive
(
:perform_async
)
expect
(
BuildEmailWorker
).
to
receive
(
:perform_async
)
service
.
execute
(
data
)
service
.
execute
(
data
)
end
end
it
"does not sends email with failed build and allowed_failure on"
do
it
'does not send email with succeeded build and notify_only_broken_builds on'
do
expect
(
service
).
to
receive
(
:notify_only_broken_builds
).
and_return
(
true
)
data
[
:build_status
]
=
'success'
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
(
data
)
end
it
'does not send email with failed build and build_allow_failure is true'
do
data
[
:build_status
]
=
'failed'
data
[
:build_status
]
=
'failed'
data
[
:build_allow_failure
]
=
true
data
[
:build_allow_failure
]
=
true
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
(
data
)
service
.
execute
(
data
)
end
end
it
'does not send email with unknown build status'
do
data
[
:build_status
]
=
'foo'
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
(
data
)
end
it
'does not send email when recipients list is empty'
do
service
.
recipients
=
' ,, '
data
[
:build_status
]
=
'failed'
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
(
data
)
end
end
end
end
end
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录