BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
5bb2840d
Commit
5bb2840d
authored
Jul 05, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'notification_when_reopened' into 'master'
Notification when reopened issue or mr Fixes #1396 See merge request !939
parents
6947d3c0
16068f3b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
0 deletions
+80
-0
merge_requests.rb
app/mailers/emails/merge_requests.rb
+12
-0
reopen_service.rb
app/services/issues/reopen_service.rb
+1
-0
reopen_service.rb
app/services/merge_requests/reopen_service.rb
+1
-0
notification_service.rb
app/services/notification_service.rb
+18
-0
merge_request_status_email.html.haml
app/views/notify/merge_request_status_email.html.haml
+2
-0
merge_request_status_email.text.haml
app/views/notify/merge_request_status_email.text.haml
+8
-0
notification_service_spec.rb
spec/services/notification_service_spec.rb
+38
-0
No files found.
app/mailers/emails/merge_requests.rb
View file @
5bb2840d
...
...
@@ -41,6 +41,18 @@ module Emails
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
end
def
merge_request_status_email
(
recipient_id
,
merge_request_id
,
status
,
updated_by_user_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@mr_status
=
status
@project
=
@merge_request
.
project
@updated_by
=
User
.
find
updated_by_user_id
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
set_reference
(
"merge_request_
#{
merge_request_id
}
"
)
mail
(
from:
sender
(
updated_by_user_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)
#{
@mr_status
}
"
))
end
end
# Over rides default behavour to show source/target
...
...
app/services/issues/reopen_service.rb
View file @
5bb2840d
...
...
@@ -4,6 +4,7 @@ module Issues
if
issue
.
reopen
event_service
.
reopen_issue
(
issue
,
current_user
)
create_note
(
issue
)
notification_service
.
reopen_issue
(
issue
,
current_user
)
execute_hooks
(
issue
,
'reopen'
)
end
...
...
app/services/merge_requests/reopen_service.rb
View file @
5bb2840d
...
...
@@ -3,6 +3,7 @@ module MergeRequests
def
execute
(
merge_request
)
if
merge_request
.
reopen
event_service
.
reopen_mr
(
merge_request
,
current_user
)
notification_service
.
reopen_mr
(
merge_request
,
current_user
)
create_note
(
merge_request
)
execute_hooks
(
merge_request
)
merge_request
.
reload_code
...
...
app/services/notification_service.rb
View file @
5bb2840d
...
...
@@ -80,6 +80,10 @@ class NotificationService
close_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'closed_merge_request_email'
)
end
def
reopen_issue
(
issue
,
current_user
)
reopen_resource_email
(
issue
,
issue
.
project
,
current_user
,
'issue_status_changed_email'
,
'reopened'
)
end
# When we merge a merge request we should send next emails:
#
# * merge_request author if their notification level is not Disabled
...
...
@@ -96,6 +100,10 @@ class NotificationService
end
end
def
reopen_mr
(
merge_request
,
current_user
)
reopen_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'merge_request_status_email'
,
'reopened'
)
end
# Notify new user with email after creation
def
new_user
(
user
)
# Don't email omniauth created users
...
...
@@ -320,6 +328,16 @@ class NotificationService
end
end
def
reopen_resource_email
(
target
,
project
,
current_user
,
method
,
status
)
recipients
=
reject_muted_users
([
target
.
author
,
target
.
assignee
],
project
)
recipients
=
recipients
.
concat
(
project_watchers
(
project
)).
uniq
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
status
,
current_user
.
id
)
end
end
def
mailer
Notify
.
delay
end
...
...
app/views/notify/merge_request_status_email.html.haml
0 → 100644
View file @
5bb2840d
%p
=
"Merge Request #
#{
@merge_request
.
iid
}
was
#{
@mr_status
}
by
#{
@updated_by
.
name
}
"
app/views/notify/merge_request_status_email.text.haml
0 → 100644
View file @
5bb2840d
=
"Merge Request #
#{
@merge_request
.
iid
}
was
#{
@mr_status
}
by
#{
@updated_by
.
name
}
"
Merge Request url:
#{
project_merge_request_url
(
@merge_request
.
target_project
,
@merge_request
)
}
=
merge_path_description
(
@merge_request
,
'to'
)
Author:
#{
@merge_request
.
author_name
}
Assignee:
#{
@merge_request
.
assignee_name
}
spec/services/notification_service_spec.rb
View file @
5bb2840d
...
...
@@ -242,6 +242,26 @@ describe NotificationService do
Notify
.
should_not_receive
(
:closed_issue_email
).
with
(
user_id
,
issue
.
id
,
@u_disabled
.
id
)
end
end
describe
:reopen_issue
do
it
'should send email to issue assignee and issue author'
do
should_email
(
issue
.
assignee_id
)
should_email
(
issue
.
author_id
)
should_email
(
@u_watcher
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
notification
.
reopen_issue
(
issue
,
@u_disabled
)
end
def
should_email
(
user_id
)
Notify
.
should_receive
(
:issue_status_changed_email
).
with
(
user_id
,
issue
.
id
,
'reopened'
,
@u_disabled
.
id
)
end
def
should_not_email
(
user_id
)
Notify
.
should_not_receive
(
:issue_status_changed_email
).
with
(
user_id
,
issue
.
id
,
'reopened'
,
@u_disabled
.
id
)
end
end
end
describe
'Merge Requests'
do
...
...
@@ -322,6 +342,24 @@ describe NotificationService do
Notify
.
should_not_receive
(
:merged_merge_request_email
).
with
(
user_id
,
merge_request
.
id
,
@u_disabled
.
id
)
end
end
describe
:reopen_merge_request
do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
notification
.
reopen_mr
(
merge_request
,
@u_disabled
)
end
def
should_email
(
user_id
)
Notify
.
should_receive
(
:merge_request_status_email
).
with
(
user_id
,
merge_request
.
id
,
'reopened'
,
@u_disabled
.
id
)
end
def
should_not_email
(
user_id
)
Notify
.
should_not_receive
(
:merge_request_status_email
).
with
(
user_id
,
merge_request
.
id
,
'reopened'
,
@u_disabled
.
id
)
end
end
end
describe
'Projects'
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