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
Léo-Paul Géneau
gitlab-ce
Commits
4cb3b71d
Commit
4cb3b71d
authored
Mar 15, 2018
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always notify new mentions even if explicitly unsubscribed
parent
feb95ce3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
4 deletions
+26
-4
app/models/notification_recipient.rb
app/models/notification_recipient.rb
+2
-1
changelogs/unreleased/43933-always-notify-mentions.yml
changelogs/unreleased/43933-always-notify-mentions.yml
+6
-0
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+18
-3
No files found.
app/models/notification_recipient.rb
View file @
4cb3b71d
...
...
@@ -35,7 +35,8 @@ class NotificationRecipient
# check this last because it's expensive
# nobody should receive notifications if they've specifically unsubscribed
return
false
if
unsubscribed?
# except if they were mentioned.
return
false
if
@type
!=
:mention
&&
unsubscribed?
true
end
...
...
changelogs/unreleased/43933-always-notify-mentions.yml
0 → 100644
View file @
4cb3b71d
---
title
:
Send @mention notifications even if a user has explicitly unsubscribed from
item
merge_request
:
author
:
type
:
added
spec/services/notification_service_spec.rb
View file @
4cb3b71d
...
...
@@ -34,6 +34,12 @@ describe NotificationService, :mailer do
should_not_email_anyone
end
it
'emails new mentions despite being unsubscribed'
do
send_notifications
(
@unsubscribed_mentioned
)
should_only_email
(
@unsubscribed_mentioned
)
end
it
'sends the proper notification reason header'
do
send_notifications
(
@u_watcher
)
should_only_email
(
@u_watcher
)
...
...
@@ -122,7 +128,7 @@ describe NotificationService, :mailer do
let
(
:project
)
{
create
(
:project
,
:private
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
assignees:
[
assignee
])
}
let
(
:mentioned_issue
)
{
create
(
:issue
,
assignees:
issue
.
assignees
)
}
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project_id:
issue
.
project_id
,
note:
'@mention referenced, @outsider also'
)
}
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project_id:
issue
.
project_id
,
note:
'@mention referenced, @
unsubscribed_mentioned and @
outsider also'
)
}
before
do
build_team
(
note
.
project
)
...
...
@@ -150,7 +156,7 @@ describe NotificationService, :mailer do
add_users_with_subscription
(
note
.
project
,
issue
)
reset_delivered_emails!
expect
(
SentNotification
).
to
receive
(
:record
).
with
(
issue
,
any_args
).
exactly
(
9
).
times
expect
(
SentNotification
).
to
receive
(
:record
).
with
(
issue
,
any_args
).
exactly
(
10
).
times
notification
.
new_note
(
note
)
...
...
@@ -163,6 +169,7 @@ describe NotificationService, :mailer do
should_email
(
@watcher_and_subscriber
)
should_email
(
@subscribed_participant
)
should_email
(
@u_custom_off
)
should_email
(
@unsubscribed_mentioned
)
should_not_email
(
@u_guest_custom
)
should_not_email
(
@u_guest_watcher
)
should_not_email
(
note
.
author
)
...
...
@@ -279,6 +286,7 @@ describe NotificationService, :mailer do
before
do
build_team
(
note
.
project
)
note
.
project
.
add_master
(
note
.
author
)
add_users_with_subscription
(
note
.
project
,
issue
)
reset_delivered_emails!
end
...
...
@@ -286,6 +294,9 @@ describe NotificationService, :mailer do
it
'notifies the team members'
do
notification
.
new_note
(
note
)
# Make sure @unsubscribed_mentioned is part of the team
expect
(
note
.
project
.
team
.
members
).
to
include
(
@unsubscribed_mentioned
)
# Notify all team members
note
.
project
.
team
.
members
.
each
do
|
member
|
# User with disabled notification should not be notified
...
...
@@ -486,7 +497,7 @@ describe NotificationService, :mailer do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
let
(
:another_project
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
let
(
:issue
)
{
create
:issue
,
project:
project
,
assignees:
[
assignee
],
description:
'cc @participant'
}
let
(
:issue
)
{
create
:issue
,
project:
project
,
assignees:
[
assignee
],
description:
'cc @participant
@unsubscribed_mentioned
'
}
before
do
build_team
(
issue
.
project
)
...
...
@@ -510,6 +521,7 @@ describe NotificationService, :mailer do
should_email
(
@u_participant_mentioned
)
should_email
(
@g_global_watcher
)
should_email
(
@g_watcher
)
should_email
(
@unsubscribed_mentioned
)
should_not_email
(
@u_mentioned
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
...
...
@@ -1823,6 +1835,7 @@ describe NotificationService, :mailer do
def
add_users_with_subscription
(
project
,
issuable
)
@subscriber
=
create
:user
@unsubscriber
=
create
:user
@unsubscribed_mentioned
=
create
:user
,
username:
'unsubscribed_mentioned'
@subscribed_participant
=
create_global_setting_for
(
create
(
:user
,
username:
'subscribed_participant'
),
:participating
)
@watcher_and_subscriber
=
create_global_setting_for
(
create
(
:user
),
:watch
)
...
...
@@ -1830,7 +1843,9 @@ describe NotificationService, :mailer do
project
.
add_master
(
@subscriber
)
project
.
add_master
(
@unsubscriber
)
project
.
add_master
(
@watcher_and_subscriber
)
project
.
add_master
(
@unsubscribed_mentioned
)
issuable
.
subscriptions
.
create
(
user:
@unsubscribed_mentioned
,
project:
project
,
subscribed:
false
)
issuable
.
subscriptions
.
create
(
user:
@subscriber
,
project:
project
,
subscribed:
true
)
issuable
.
subscriptions
.
create
(
user:
@subscribed_participant
,
project:
project
,
subscribed:
true
)
issuable
.
subscriptions
.
create
(
user:
@unsubscriber
,
project:
project
,
subscribed:
false
)
...
...
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