Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7fb1bb01
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,发现更多精彩内容 >>
提交
7fb1bb01
编写于
11月 25, 2017
作者:
G
George Andrinopoulos
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create issue and merge request destroy services
上级
d199ecd4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
59 addition
and
5 deletion
+59
-5
app/controllers/concerns/issuable_actions.rb
app/controllers/concerns/issuable_actions.rb
+1
-1
app/models/issue.rb
app/models/issue.rb
+0
-1
app/models/merge_request.rb
app/models/merge_request.rb
+0
-1
app/services/issuable/destroy_service.rb
app/services/issuable/destroy_service.rb
+9
-0
changelogs/unreleased/39601-create-issuable-destroy-service.yml
...logs/unreleased/39601-create-issuable-destroy-service.yml
+5
-0
lib/api/issues.rb
lib/api/issues.rb
+3
-1
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+3
-1
spec/services/issuable/destroy_service_spec.rb
spec/services/issuable/destroy_service_spec.rb
+38
-0
未找到文件。
app/controllers/concerns/issuable_actions.rb
浏览文件 @
7fb1bb01
...
...
@@ -54,7 +54,7 @@ module IssuableActions
end
def
destroy
issuable
.
destroy
Issuable
::
DestroyService
.
new
(
project
,
current_user
).
execute
(
issuable
)
TodoService
.
new
.
destroy_issuable
(
issuable
,
current_user
)
name
=
issuable
.
human_class_name
...
...
app/models/issue.rb
浏览文件 @
7fb1bb01
...
...
@@ -49,7 +49,6 @@ class Issue < ActiveRecord::Base
scope
:public_only
,
->
{
where
(
confidential:
false
)
}
after_save
:expire_etag_cache
after_commit
:update_project_counter_caches
,
on: :destroy
attr_spammable
:title
,
spam_title:
true
attr_spammable
:description
,
spam_description:
true
...
...
app/models/merge_request.rb
浏览文件 @
7fb1bb01
...
...
@@ -52,7 +52,6 @@ class MergeRequest < ActiveRecord::Base
after_create
:ensure_merge_request_diff
,
unless: :importing?
after_update
:reload_diff_if_branch_changed
after_commit
:update_project_counter_caches
,
on: :destroy
# When this attribute is true some MR validation is ignored
# It allows us to close or modify broken merge requests
...
...
app/services/issuable/destroy_service.rb
0 → 100644
浏览文件 @
7fb1bb01
module
Issuable
class
DestroyService
<
IssuableBaseService
def
execute
(
issuable
)
if
issuable
.
destroy
issuable
.
update_project_counter_caches
end
end
end
end
changelogs/unreleased/39601-create-issuable-destroy-service.yml
0 → 100644
浏览文件 @
7fb1bb01
---
title
:
Create issuable destroy service
merge_request
:
15604
author
:
George Andrinopoulos
type
:
other
lib/api/issues.rb
浏览文件 @
7fb1bb01
...
...
@@ -255,7 +255,9 @@ module API
authorize!
(
:destroy_issue
,
issue
)
destroy_conditionally!
(
issue
)
destroy_conditionally!
(
issue
)
do
|
issue
|
Issuable
::
DestroyService
.
new
(
user_project
,
current_user
).
execute
(
issue
)
end
end
desc
'List merge requests closing issue'
do
...
...
lib/api/merge_requests.rb
浏览文件 @
7fb1bb01
...
...
@@ -167,7 +167,9 @@ module API
authorize!
(
:destroy_merge_request
,
merge_request
)
destroy_conditionally!
(
merge_request
)
destroy_conditionally!
(
merge_request
)
do
|
merge_request
|
Issuable
::
DestroyService
.
new
(
user_project
,
current_user
).
execute
(
merge_request
)
end
end
params
do
...
...
spec/services/issuable/destroy_service_spec.rb
0 → 100644
浏览文件 @
7fb1bb01
require
'spec_helper'
describe
Issuable
::
DestroyService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
describe
'#execute'
do
context
'when issuable is an issue'
do
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
it
'destroys the issue'
do
expect
{
service
.
execute
(
issue
)
}.
to
change
{
project
.
issues
.
count
}.
by
(
-
1
)
end
it
'updates open issues count cache'
do
expect_any_instance_of
(
Projects
::
OpenIssuesCountService
).
to
receive
(
:refresh_cache
)
service
.
execute
(
issue
)
end
end
context
'when issuable is a merge request'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
target_project:
project
,
source_project:
project
,
author:
user
)
}
it
'destroys the merge request'
do
expect
{
service
.
execute
(
merge_request
)
}.
to
change
{
project
.
merge_requests
.
count
}.
by
(
-
1
)
end
it
'updates open merge requests count cache'
do
expect_any_instance_of
(
Projects
::
OpenMergeRequestsCountService
).
to
receive
(
:refresh_cache
)
service
.
execute
(
merge_request
)
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录