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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
15d32b6a
Commit
15d32b6a
authored
Mar 15, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new notifications for issue move action
[ci skip]
parent
a23f0e8c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
3 deletions
+63
-3
app/mailers/emails/issues.rb
app/mailers/emails/issues.rb
+8
-0
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+7
-2
app/services/notification_service.rb
app/services/notification_service.rb
+10
-0
app/views/notify/issue_moved_email.html.haml
app/views/notify/issue_moved_email.html.haml
+6
-0
app/views/notify/issue_moved_email.text.erb
app/views/notify/issue_moved_email.text.erb
+4
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+27
-0
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+1
-1
No files found.
app/mailers/emails/issues.rb
View file @
15d32b6a
...
@@ -36,6 +36,14 @@ module Emails
...
@@ -36,6 +36,14 @@ module Emails
mail_answer_thread
(
@issue
,
issue_thread_options
(
updated_by_user_id
,
recipient_id
))
mail_answer_thread
(
@issue
,
issue_thread_options
(
updated_by_user_id
,
recipient_id
))
end
end
def
issue_moved_email
(
recipient
,
issue
,
new_issue
,
updated_by_user
)
setup_issue_mail
(
issue
.
id
,
recipient
.
id
)
@new_issue
=
new_issue
@new_project
=
new_issue
.
project
mail_answer_thread
(
issue
,
issue_thread_options
(
updated_by_user
.
id
,
recipient
.
id
))
end
private
private
def
setup_issue_mail
(
issue_id
,
recipient_id
)
def
setup_issue_mail
(
issue_id
,
recipient_id
)
...
...
app/services/issues/move_service.rb
View file @
15d32b6a
...
@@ -10,13 +10,17 @@ module Issues
...
@@ -10,13 +10,17 @@ module Issues
if
new_project_id
if
new_project_id
@project_new
=
Project
.
find
(
new_project_id
)
@project_new
=
Project
.
find
(
new_project_id
)
end
end
if
@project_new
==
@project_old
raise
StandardError
,
'Cannot move issue to project it originates from!'
end
end
end
def
execute
def
execute
return
unless
move?
return
unless
move?
# Using trasaction because of a high
footprint on
# Using trasaction because of a high
resources footprint
# rewriting notes (unfolding references)
#
on
rewriting notes (unfolding references)
#
#
ActiveRecord
::
Base
.
transaction
do
ActiveRecord
::
Base
.
transaction
do
# New issue tasks
# New issue tasks
...
@@ -99,6 +103,7 @@ module Issues
...
@@ -99,6 +103,7 @@ module Issues
end
end
def
notify_participants
def
notify_participants
notification_service
.
issue_moved
(
@issue_old
,
@issue_new
,
@current_user
)
end
end
end
end
end
end
app/services/notification_service.rb
View file @
15d32b6a
...
@@ -236,6 +236,16 @@ class NotificationService
...
@@ -236,6 +236,16 @@ class NotificationService
end
end
end
end
def
issue_moved
(
issue
,
new_issue
,
current_user
)
recipients
=
build_recipients
(
issue
,
issue
.
project
,
current_user
)
recipients
.
map
do
|
recipient
|
email
=
mailer
.
issue_moved_email
(
recipient
,
issue
,
new_issue
,
current_user
)
email
.
deliver_later
email
end
end
protected
protected
# Get project users with WATCH notification level
# Get project users with WATCH notification level
...
...
app/views/notify/issue_moved_email.html.haml
0 → 100644
View file @
15d32b6a
%p
Issue was moved to another project.
%p
New issue:
=
link_to
namespace_project_issue_url
(
@new_project
.
namespace
,
@new_project
,
@new_issue
)
do
=
@new_issue
.
title
app/views/notify/issue_moved_email.text.erb
0 → 100644
View file @
15d32b6a
Issue was moved to another project.
New issue location:
<%=
namespace_project_issue_url
(
@new_project
.
namespace
,
@new_project
,
@new_issue
)
%>
spec/mailers/notify_spec.rb
View file @
15d32b6a
...
@@ -158,6 +158,33 @@ describe Notify do
...
@@ -158,6 +158,33 @@ describe Notify do
is_expected
.
to
have_body_text
/
#{
namespace_project_issue_path
project
.
namespace
,
project
,
issue
}
/
is_expected
.
to
have_body_text
/
#{
namespace_project_issue_path
project
.
namespace
,
project
,
issue
}
/
end
end
end
end
describe
'moved to another project'
do
let
(
:new_issue
)
{
create
(
:issue
)
}
subject
{
Notify
.
issue_moved_email
(
recipient
,
issue
,
new_issue
,
current_user
)
}
it_behaves_like
'an answer to an existing thread'
,
'issue'
it_behaves_like
'it should show Gmail Actions View Issue link'
it_behaves_like
'an unsubscribeable thread'
it
'contains description about action taken'
do
is_expected
.
to
have_body_text
'Issue was moved to another project'
end
it
'has the correct subject'
do
is_expected
.
to
have_subject
/
#{
issue
.
title
}
\(#
#{
issue
.
iid
}
\)/i
end
it
'contains link to new issue'
do
new_issue_url
=
namespace_project_issue_path
(
new_issue
.
project
.
namespace
,
new_issue
.
project
,
new_issue
)
is_expected
.
to
have_body_text
new_issue_url
end
it
'contains a link to the original issue'
do
is_expected
.
to
have_body_text
/
#{
namespace_project_issue_path
project
.
namespace
,
project
,
issue
}
/
end
end
end
end
context
'for merge requests'
do
context
'for merge requests'
do
...
...
spec/services/issues/move_service_spec.rb
View file @
15d32b6a
...
@@ -55,7 +55,7 @@ describe Issues::MoveService, services: true do
...
@@ -55,7 +55,7 @@ describe Issues::MoveService, services: true do
end
end
it
'rewrites issue description'
do
it
'rewrites issue description'
do
expect
(
new_issue
.
description
).
to
include
description
expect
(
new_issue
.
description
).
to
eq
description
end
end
it
'adds system note to old issue at the end'
do
it
'adds system note to old issue at the end'
do
...
...
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