Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
04a8db0a
Commit
04a8db0a
authored
Feb 07, 2022
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy contacts when moving an issue
Changelog: added
parent
34760e19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+17
-0
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+42
-0
No files found.
app/services/issues/move_service.rb
View file @
04a8db0a
...
...
@@ -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 @@ module Issues
.
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 @@ module Issues
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 @@ module 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
View file @
04a8db0a
...
...
@@ -168,6 +168,48 @@ RSpec.describe Issues::MoveService do
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
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment