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
668cdfcd
Commit
668cdfcd
authored
Feb 20, 2020
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update moved service desk issues notifications
Allows service desk emails to be received at the new moved issue.
parent
06c4b0c5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
0 deletions
+90
-0
app/models/issue.rb
app/models/issue.rb
+2
-0
changelogs/unreleased/issue_11391.yml
changelogs/unreleased/issue_11391.yml
+5
-0
ee/app/models/ee/issue.rb
ee/app/models/ee/issue.rb
+4
-0
ee/app/services/ee/issues/move_service.rb
ee/app/services/ee/issues/move_service.rb
+18
-0
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+16
-0
ee/spec/services/ee/issues/move_service_spec.rb
ee/spec/services/ee/issues/move_service_spec.rb
+43
-0
lib/gitlab/import_export/project/import_export.yml
lib/gitlab/import_export/project/import_export.yml
+1
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
No files found.
app/models/issue.rb
View file @
668cdfcd
...
...
@@ -44,6 +44,8 @@ class Issue < ApplicationRecord
has_many
:assignees
,
class_name:
"User"
,
through: :issue_assignees
has_many
:zoom_meetings
has_many
:user_mentions
,
class_name:
"IssueUserMention"
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:sent_notifications
,
as: :noteable
has_one
:sentry_issue
accepts_nested_attributes_for
:sentry_issue
...
...
changelogs/unreleased/issue_11391.yml
0 → 100644
View file @
668cdfcd
---
title
:
Update moved service desk issues notifications
merge_request
:
25640
author
:
type
:
added
ee/app/models/ee/issue.rb
View file @
668cdfcd
...
...
@@ -161,6 +161,10 @@ module EE
IssueLink
.
inverse_link_type
(
type
)
end
def
from_service_desk?
author
.
id
==
::
User
.
support_bot
.
id
end
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
...
...
ee/app/services/ee/issues/move_service.rb
View file @
668cdfcd
...
...
@@ -5,6 +5,17 @@ module EE
module
MoveService
extend
::
Gitlab
::
Utils
::
Override
override
:execute
def
execute
(
issue
,
target_project
)
super
# Updates old issue sent notifications allowing
# to receive service desk emails on the new moved issue.
update_service_desk_sent_notifications
new_entity
end
override
:update_old_entity
def
update_old_entity
rewrite_epic_issue
...
...
@@ -14,6 +25,13 @@ module EE
private
def
update_service_desk_sent_notifications
return
unless
original_entity
.
from_service_desk?
original_entity
.
sent_notifications
.
update_all
(
project_id:
new_entity
.
project_id
,
noteable_id:
new_entity
.
id
)
end
def
rewrite_epic_issue
return
unless
epic_issue
=
original_entity
.
epic_issue
return
unless
can?
(
current_user
,
:update_epic
,
epic_issue
.
epic
.
group
)
...
...
ee/spec/models/issue_spec.rb
View file @
668cdfcd
...
...
@@ -615,4 +615,20 @@ describe Issue do
end
it_behaves_like
'having health status'
describe
'#service_desk?'
do
subject
{
issue
.
from_service_desk?
}
context
'when issue author is support bot'
do
let
(
:issue
)
{
create
(
:issue
,
author:
::
User
.
support_bot
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
'when issue author is not support bot'
do
let
(
:issue
)
{
create
(
:issue
)
}
it
{
is_expected
.
to
be_falsey
}
end
end
end
ee/spec/services/ee/issues/move_service_spec.rb
View file @
668cdfcd
...
...
@@ -107,4 +107,47 @@ describe Issues::MoveService do
end
end
end
context
'updating sent notifications'
do
let!
(
:old_issue_notification_1
)
{
create
(
:sent_notification
,
project:
old_issue
.
project
,
noteable:
old_issue
)
}
let!
(
:old_issue_notification_2
)
{
create
(
:sent_notification
,
project:
old_issue
.
project
,
noteable:
old_issue
)
}
let!
(
:other_issue_notification
)
{
create
(
:sent_notification
,
project:
old_issue
.
project
)
}
context
'when issue is from service desk'
do
before
do
allow
(
old_issue
).
to
receive
(
:from_service_desk?
).
and_return
(
true
)
end
it
'updates moved issue sent notifications'
do
new_issue
=
move_service
.
execute
(
old_issue
,
new_project
)
old_issue_notification_1
.
reload
old_issue_notification_2
.
reload
expect
(
old_issue_notification_1
.
project_id
).
to
eq
(
new_issue
.
project_id
)
expect
(
old_issue_notification_1
.
noteable_id
).
to
eq
(
new_issue
.
id
)
expect
(
old_issue_notification_2
.
project_id
).
to
eq
(
new_issue
.
project_id
)
expect
(
old_issue_notification_2
.
noteable_id
).
to
eq
(
new_issue
.
id
)
end
it
'does not update other issues sent notifications'
do
expect
do
move_service
.
execute
(
old_issue
,
new_project
)
other_issue_notification
.
reload
end
.
not_to
change
{
other_issue_notification
.
noteable_id
}
end
end
context
'when issue is not from service desk'
do
it
'does not update sent notifications'
do
move_service
.
execute
(
old_issue
,
new_project
)
old_issue_notification_1
.
reload
old_issue_notification_2
.
reload
expect
(
old_issue_notification_1
.
project_id
).
to
eq
(
old_issue
.
project_id
)
expect
(
old_issue_notification_1
.
noteable_id
).
to
eq
(
old_issue
.
id
)
expect
(
old_issue_notification_2
.
project_id
).
to
eq
(
old_issue
.
project_id
)
expect
(
old_issue_notification_2
.
noteable_id
).
to
eq
(
old_issue
.
id
)
end
end
end
end
lib/gitlab/import_export/project/import_export.yml
View file @
668cdfcd
...
...
@@ -188,6 +188,7 @@ excluded_attributes:
issues
:
-
:milestone_id
-
:moved_to_id
-
:sent_notifications
-
:state_id
-
:duplicated_to_id
-
:promoted_to_epic_id
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
668cdfcd
...
...
@@ -10,6 +10,7 @@ issues:
-
resource_label_events
-
resource_weight_events
-
resource_milestone_events
-
sent_notifications
-
sentry_issue
-
label_links
-
labels
...
...
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