Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
21f10af0
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 搜索 >>
提交
21f10af0
编写于
8月 30, 2016
作者:
D
Douglas Barbosa Alexandre
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Scope hooks thal will run for confidential issues
上级
dd64f8aa
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
55 addition
and
22 deletion
+55
-22
app/models/hooks/project_hook.rb
app/models/hooks/project_hook.rb
+1
-0
app/models/service.rb
app/models/service.rb
+1
-0
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+4
-5
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+12
-3
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+12
-3
spec/services/issues/reopen_service_spec.rb
spec/services/issues/reopen_service_spec.rb
+22
-8
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+3
-3
未找到文件。
app/models/hooks/project_hook.rb
浏览文件 @
21f10af0
...
...
@@ -2,6 +2,7 @@ class ProjectHook < WebHook
belongs_to
:project
scope
:issue_hooks
,
->
{
where
(
issues_events:
true
)
}
scope
:confidential_issue_hooks
,
->
{
where
(
confidential_issues_events:
true
)
}
scope
:note_hooks
,
->
{
where
(
note_events:
true
)
}
scope
:merge_request_hooks
,
->
{
where
(
merge_requests_events:
true
)
}
scope
:build_hooks
,
->
{
where
(
build_events:
true
)
}
...
...
app/models/service.rb
浏览文件 @
21f10af0
...
...
@@ -34,6 +34,7 @@ class Service < ActiveRecord::Base
scope
:push_hooks
,
->
{
where
(
push_events:
true
,
active:
true
)
}
scope
:tag_push_hooks
,
->
{
where
(
tag_push_events:
true
,
active:
true
)
}
scope
:issue_hooks
,
->
{
where
(
issues_events:
true
,
active:
true
)
}
scope
:confidential_issue_hooks
,
->
{
where
(
confidential_issues_events:
true
,
active:
true
)
}
scope
:merge_request_hooks
,
->
{
where
(
merge_requests_events:
true
,
active:
true
)
}
scope
:note_hooks
,
->
{
where
(
note_events:
true
,
active:
true
)
}
scope
:build_hooks
,
->
{
where
(
build_events:
true
,
active:
true
)
}
...
...
app/services/issues/base_service.rb
浏览文件 @
21f10af0
...
...
@@ -14,11 +14,10 @@ module Issues
end
def
execute_hooks
(
issue
,
action
=
'open'
)
return
if
issue
.
confidential?
issue_data
=
hook_data
(
issue
,
action
)
issue
.
project
.
execute_hooks
(
issue_data
,
:issue_hooks
)
issue
.
project
.
execute_services
(
issue_data
,
:issue_hooks
)
issue_data
=
hook_data
(
issue
,
action
)
hooks_scope
=
issue
.
confidential?
?
:confidential_issue_hooks
:
:issue_hooks
issue
.
project
.
execute_hooks
(
issue_data
,
hooks_scope
)
issue
.
project
.
execute_services
(
issue_data
,
hooks_scope
)
end
end
end
spec/services/issues/close_service_spec.rb
浏览文件 @
21f10af0
...
...
@@ -53,12 +53,21 @@ describe Issues::CloseService, services: true do
end
end
context
'when issue is not confidential'
do
it
'executes issue hooks'
do
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
end
context
'when issue is confidential'
do
it
'
does not execut
e hooks'
do
it
'
executes confidential issu
e hooks'
do
issue
=
create
(
:issue
,
:confidential
,
project:
project
)
expect
(
project
).
not_to
receive
(
:execut
e_hooks
)
expect
(
project
).
not_to
receive
(
:execute_service
s
)
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:confidential_issu
e_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hook
s
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
...
...
spec/services/issues/create_service_spec.rb
浏览文件 @
21f10af0
...
...
@@ -73,11 +73,20 @@ describe Issues::CreateService, services: true do
end
end
it
'does not execute hooks when issue is confidential'
do
it
'executes issue hooks when issue is not confidential'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
confidential:
false
}
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
described_class
.
new
(
project
,
user
,
opts
).
execute
end
it
'executes confidential issue hooks when issue is confidential'
do
opts
=
{
title:
'Title'
,
description:
'Description'
,
confidential:
true
}
expect
(
project
).
not_to
receive
(
:execut
e_hooks
)
expect
(
project
).
not_to
receive
(
:execute_service
s
)
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:confidential_issu
e_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hook
s
)
described_class
.
new
(
project
,
user
,
opts
).
execute
end
...
...
spec/services/issues/reopen_service_spec.rb
浏览文件 @
21f10af0
...
...
@@ -5,7 +5,7 @@ describe Issues::ReopenService, services: true do
let
(
:issue
)
{
create
(
:issue
,
:closed
,
project:
project
)
}
describe
'#execute'
do
context
'
current
user is not authorized to reopen issue'
do
context
'
when
user is not authorized to reopen issue'
do
before
do
guest
=
create
(
:user
)
project
.
team
<<
[
guest
,
:guest
]
...
...
@@ -20,17 +20,31 @@ describe Issues::ReopenService, services: true do
end
end
context
'when issue is confidential'
do
it
'does not execute hooks'
do
user
=
create
(
:user
)
context
'when user is authrized to reopen issue'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
user
,
:master
]
end
context
'when issue is not confidential'
do
it
'executes issue hooks'
do
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
issue
=
create
(
:issue
,
:confidential
,
:closed
,
project:
project
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
end
expect
(
project
).
not_to
receive
(
:execute_hooks
)
expect
(
project
).
not_to
receive
(
:execute_services
)
context
'when issue is confidential'
do
it
'executes confidential issue hooks'
do
issue
=
create
(
:issue
,
:confidential
,
:closed
,
project:
project
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hooks
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
end
end
end
...
...
spec/services/issues/update_service_spec.rb
浏览文件 @
21f10af0
...
...
@@ -105,9 +105,9 @@ describe Issues::UpdateService, services: true do
expect
(
note
.
note
).
to
eq
'Made the issue confidential'
end
it
'
does not execut
e hooks'
do
expect
(
project
).
not_to
receive
(
:execut
e_hooks
)
expect
(
project
).
not_to
receive
(
:execute_service
s
)
it
'
executes confidential issu
e hooks'
do
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:confidential_issu
e_hooks
)
expect
(
project
).
to
receive
(
:execute_services
).
with
(
an_instance_of
(
Hash
),
:confidential_issue_hook
s
)
update_issue
(
confidential:
true
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录