Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b13bed62
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,发现更多精彩内容 >>
提交
b13bed62
编写于
3月 23, 2015
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up code by using keyword arguments.
上级
bf235053
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
28 addition
and
16 deletion
+28
-16
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+7
-1
app/models/project_services/emails_on_push_service.rb
app/models/project_services/emails_on_push_service.rb
+7
-1
app/workers/emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+8
-8
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+6
-6
未找到文件。
app/mailers/emails/projects.rb
浏览文件 @
b13bed62
...
@@ -16,7 +16,13 @@ module Emails
...
@@ -16,7 +16,13 @@ module Emails
subject:
subject
(
"Project was moved"
))
subject:
subject
(
"Project was moved"
))
end
end
def
repository_push_email
(
project_id
,
recipient
,
author_id
,
ref
,
action
,
compare
,
reverse_compare
=
false
,
send_from_committer_email
=
false
,
disable_diffs
=
false
)
def
repository_push_email
(
project_id
,
recipient
,
author_id
:,
ref
:,
action
:,
compare:
nil
,
reverse_compare:
false
,
send_from_committer_email:
false
,
disable_diffs:
false
)
@project
=
Project
.
find
(
project_id
)
@project
=
Project
.
find
(
project_id
)
@author
=
User
.
find
(
author_id
)
@author
=
User
.
find
(
author_id
)
@reverse_compare
=
reverse_compare
@reverse_compare
=
reverse_compare
...
...
app/models/project_services/emails_on_push_service.rb
浏览文件 @
b13bed62
...
@@ -42,7 +42,13 @@ class EmailsOnPushService < Service
...
@@ -42,7 +42,13 @@ class EmailsOnPushService < Service
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
])
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
push_data
,
send_from_committer_email?
,
disable_diffs?
)
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
push_data
,
send_from_committer_email:
send_from_committer_email?
,
disable_diffs:
disable_diffs?
)
end
end
def
send_from_committer_email?
def
send_from_committer_email?
...
...
app/workers/emails_on_push_worker.rb
浏览文件 @
b13bed62
class
EmailsOnPushWorker
class
EmailsOnPushWorker
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
def
perform
(
project_id
,
recipients
,
push_data
,
send_from_committer_email
=
false
,
disable_diffs
=
false
)
def
perform
(
project_id
,
recipients
,
push_data
,
send_from_committer_email
:
false
,
disable_diffs:
false
)
project
=
Project
.
find
(
project_id
)
project
=
Project
.
find
(
project_id
)
before_sha
=
push_data
[
"before"
]
before_sha
=
push_data
[
"before"
]
after_sha
=
push_data
[
"after"
]
after_sha
=
push_data
[
"after"
]
...
@@ -37,13 +37,13 @@ class EmailsOnPushWorker
...
@@ -37,13 +37,13 @@ class EmailsOnPushWorker
Notify
.
repository_push_email
(
Notify
.
repository_push_email
(
project_id
,
project_id
,
recipient
,
recipient
,
author_id
,
author_id
:
author_id
,
ref
,
ref
:
ref
,
action
,
action
:
action
,
compare
,
compare
:
compare
,
reverse_compare
,
reverse_compare
:
reverse_compare
,
send_from_committer_email
,
send_from_committer_email
:
send_from_committer_email
,
disable_diffs
disable_diffs
:
disable_diffs
).
deliver
).
deliver
end
end
ensure
ensure
...
...
spec/mailers/notify_spec.rb
浏览文件 @
b13bed62
...
@@ -645,7 +645,7 @@ describe Notify do
...
@@ -645,7 +645,7 @@ describe Notify do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:tree_path
)
{
namespace_project_tree_path
(
project
.
namespace
,
project
,
"master"
)
}
let
(
:tree_path
)
{
namespace_project_tree_path
(
project
.
namespace
,
project
,
"master"
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/heads/master'
,
:create
,
nil
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :create
)
}
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -671,7 +671,7 @@ describe Notify do
...
@@ -671,7 +671,7 @@ describe Notify do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:tree_path
)
{
namespace_project_tree_path
(
project
.
namespace
,
project
,
"v1.0"
)
}
let
(
:tree_path
)
{
namespace_project_tree_path
(
project
.
namespace
,
project
,
"v1.0"
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/tags/v1.0'
,
:create
,
nil
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :create
)
}
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -696,7 +696,7 @@ describe Notify do
...
@@ -696,7 +696,7 @@ describe Notify do
let
(
:example_site_path
)
{
root_path
}
let
(
:example_site_path
)
{
root_path
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/heads/master'
,
:delete
,
nil
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :delete
)
}
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -717,7 +717,7 @@ describe Notify do
...
@@ -717,7 +717,7 @@ describe Notify do
let
(
:example_site_path
)
{
root_path
}
let
(
:example_site_path
)
{
root_path
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/tags/v1.0'
,
:delete
,
nil
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :delete
)
}
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -742,7 +742,7 @@ describe Notify do
...
@@ -742,7 +742,7 @@ describe Notify do
let
(
:diff_path
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
Commit
.
new
(
compare
.
base
),
to:
Commit
.
new
(
compare
.
head
))
}
let
(
:diff_path
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
Commit
.
new
(
compare
.
base
),
to:
Commit
.
new
(
compare
.
head
))
}
let
(
:send_from_committer_email
)
{
false
}
let
(
:send_from_committer_email
)
{
false
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/heads/master'
,
:push
,
compare
,
false
,
send_from_committer_email
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
reverse_compare:
false
,
send_from_committer_email:
send_from_committer_email
)
}
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -830,7 +830,7 @@ describe Notify do
...
@@ -830,7 +830,7 @@ describe Notify do
let
(
:commits
)
{
Commit
.
decorate
(
compare
.
commits
)
}
let
(
:commits
)
{
Commit
.
decorate
(
compare
.
commits
)
}
let
(
:diff_path
)
{
namespace_project_commit_path
(
project
.
namespace
,
project
,
commits
.
first
)
}
let
(
:diff_path
)
{
namespace_project_commit_path
(
project
.
namespace
,
project
,
commits
.
first
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/heads/master'
,
:push
,
compare
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
)
}
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录