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
70947fed
Commit
70947fed
authored
Mar 28, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inslude author & assignee to note notification recipients
parent
61824973
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
28 deletions
+61
-28
app/services/notification_service.rb
app/services/notification_service.rb
+3
-1
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+58
-27
No files found.
app/services/notification_service.rb
View file @
70947fed
...
@@ -106,12 +106,14 @@ class NotificationService
...
@@ -106,12 +106,14 @@ class NotificationService
if
note
.
commit_id
if
note
.
commit_id
opts
.
merge!
(
commit_id:
note
.
commit_id
)
opts
.
merge!
(
commit_id:
note
.
commit_id
)
recipients
=
[
note
.
commit_author
]
else
else
opts
.
merge!
(
noteable_id:
note
.
noteable_id
)
opts
.
merge!
(
noteable_id:
note
.
noteable_id
)
recipients
=
[
note
.
noteable
.
try
(
:author
),
note
.
noteable
.
try
(
:assignee
)]
end
end
# Get users who left comment in thread
# Get users who left comment in thread
recipients
=
User
.
where
(
id:
Note
.
where
(
opts
).
pluck
(
:author_id
))
recipients
=
recipients
.
concat
(
User
.
where
(
id:
Note
.
where
(
opts
).
pluck
(
:author_id
)
))
# Merge project watchers
# Merge project watchers
recipients
=
recipients
.
concat
(
project_watchers
(
note
.
project
)).
compact
.
uniq
recipients
=
recipients
.
concat
(
project_watchers
(
note
.
project
)).
compact
.
uniq
...
...
spec/services/notification_service_spec.rb
View file @
70947fed
...
@@ -21,40 +21,71 @@ describe NotificationService do
...
@@ -21,40 +21,71 @@ describe NotificationService do
end
end
describe
'Notes'
do
describe
'Notes'
do
let
(
:note
)
{
create
:note_on_commit
}
context
'issue note'
do
let
(
:issue
)
{
create
(
:issue
,
assignee:
create
(
:user
))
}
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project_id:
issue
.
project_id
)
}
before
do
before
do
build_team
(
note
.
project
)
build_team
(
note
.
project
)
end
describe
:new_note
do
it
do
should_email
(
@u_watcher
.
id
)
should_not_email
(
note
.
author_id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
notification
.
new_note
(
note
)
end
end
it
do
describe
:new_note
do
create
(
:note_on_commit
,
it
do
author:
@u_participating
,
should_email
(
@u_watcher
.
id
)
project_id:
note
.
project_id
,
should_email
(
note
.
noteable
.
author_id
)
commit_id:
note
.
commit_id
)
should_email
(
note
.
noteable
.
assignee_id
)
should_not_email
(
note
.
author_id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
notification
.
new_note
(
note
)
end
should_email
(
@u_watcher
.
id
)
def
should_email
(
user_id
)
should_email
(
@u_participating
.
id
)
Notify
.
should_receive
(
:note_issue_email
).
with
(
user_id
,
note
.
id
)
should_not_email
(
note
.
author_id
)
end
should_not_email
(
@u_disabled
.
id
)
notification
.
new_note
(
note
)
end
def
should_email
(
user_id
)
def
should_not_email
(
user_id
)
Notify
.
should_receive
(
:note_commit_email
).
with
(
user_id
,
note
.
id
)
Notify
.
should_not_receive
(
:note_issue_email
).
with
(
user_id
,
note
.
id
)
end
end
end
end
def
should_not_email
(
user_id
)
context
'commit note'
do
Notify
.
should_not_receive
(
:note_commit_email
).
with
(
user_id
,
note
.
id
)
let
(
:note
)
{
create
:note_on_commit
}
before
do
build_team
(
note
.
project
)
end
describe
:new_note
do
it
do
should_email
(
@u_watcher
.
id
)
should_not_email
(
note
.
author_id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
notification
.
new_note
(
note
)
end
it
do
create
(
:note_on_commit
,
author:
@u_participating
,
project_id:
note
.
project_id
,
commit_id:
note
.
commit_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participating
.
id
)
should_not_email
(
note
.
author_id
)
should_not_email
(
@u_disabled
.
id
)
notification
.
new_note
(
note
)
end
def
should_email
(
user_id
)
Notify
.
should_receive
(
:note_commit_email
).
with
(
user_id
,
note
.
id
)
end
def
should_not_email
(
user_id
)
Notify
.
should_not_receive
(
:note_commit_email
).
with
(
user_id
,
note
.
id
)
end
end
end
end
end
end
end
...
...
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