Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
56c44a68
提交
56c44a68
编辑于
3 years ago
作者:
Andy Soiron
浏览文件
操作
下载
差异文件
Merge branch '352134-move-issues-contacts' into 'master'
Copy contacts when moving an issue See merge request gitlab-org/gitlab!80069
上级
1fc1c63e
04a8db0a
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
app/services/issues/move_service.rb
+17
-0
17 个添加, 0 个删除
app/services/issues/move_service.rb
spec/services/issues/move_service_spec.rb
+42
-0
42 个添加, 0 个删除
spec/services/issues/move_service_spec.rb
有
59 个添加
和
0 个删除
app/services/issues/move_service.rb
+
17
−
0
浏览文件 @
56c44a68
...
...
@@ -2,6 +2,8 @@
module
Issues
class
MoveService
<
Issuable
::
Clone
::
BaseService
extend
::
Gitlab
::
Utils
::
Override
MoveError
=
Class
.
new
(
StandardError
)
def
execute
(
issue
,
target_project
)
...
...
@@ -47,6 +49,7 @@ def update_service_desk_sent_notifications
.
sent_notifications
.
update_all
(
project_id:
new_entity
.
project_id
,
noteable_id:
new_entity
.
id
)
end
override
:update_old_entity
def
update_old_entity
super
...
...
@@ -54,6 +57,13 @@ def update_old_entity
mark_as_moved
end
override
:update_new_entity
def
update_new_entity
super
copy_contacts
end
def
create_new_entity
new_params
=
{
id:
nil
,
...
...
@@ -99,6 +109,13 @@ def rewrite_related_issues
target_issue_links
.
update_all
(
target_id:
new_entity
.
id
)
end
def
copy_contacts
return
unless
Feature
.
enabled?
(
:customer_relations
,
original_entity
.
project
.
root_ancestor
)
return
unless
original_entity
.
project
.
root_ancestor
==
new_entity
.
project
.
root_ancestor
new_entity
.
customer_relations_contacts
=
original_entity
.
customer_relations_contacts
end
def
notify_participants
notification_service
.
async
.
issue_moved
(
original_entity
,
new_entity
,
@current_user
)
end
...
...
此差异已折叠。
点击以展开。
spec/services/issues/move_service_spec.rb
+
42
−
0
浏览文件 @
56c44a68
...
...
@@ -168,6 +168,48 @@
end
end
context
'issue with contacts'
do
let_it_be
(
:contacts
)
{
create_list
(
:contact
,
2
,
group:
group
)
}
before
do
old_issue
.
customer_relations_contacts
=
contacts
end
it
'preserves contacts'
do
new_issue
=
move_service
.
execute
(
old_issue
,
new_project
)
expect
(
new_issue
.
customer_relations_contacts
).
to
eq
(
contacts
)
end
context
'when moving to another root group'
do
let
(
:another_project
)
{
create
(
:project
,
namespace:
create
(
:group
))
}
before
do
another_project
.
add_reporter
(
user
)
end
it
'does not preserve contacts'
do
new_issue
=
move_service
.
execute
(
old_issue
,
another_project
)
expect
(
new_issue
.
customer_relations_contacts
).
to
be_empty
end
end
context
'when customer_relations feature is disabled'
do
let
(
:another_project
)
{
create
(
:project
,
namespace:
create
(
:group
))
}
before
do
stub_feature_flags
(
customer_relations:
false
)
end
it
'does not preserve contacts'
do
new_issue
=
move_service
.
execute
(
old_issue
,
new_project
)
expect
(
new_issue
.
customer_relations_contacts
).
to
be_empty
end
end
end
context
'moving to same project'
do
let
(
:new_project
)
{
old_project
}
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录