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
e5ed2e4f
Commit
e5ed2e4f
authored
Oct 10, 2017
by
micael.bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix multiple notifications from being sent for multiple labels
This also refactor the email_helper support spec to watch for multiple emails being sent.
parent
f9df0e13
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
8 deletions
+20
-8
notification_service.rb
app/services/notification_service.rb
+1
-1
notification_service_spec.rb
spec/services/notification_service_spec.rb
+12
-0
email_helpers.rb
spec/support/email_helpers.rb
+7
-7
No files found.
app/services/notification_service.rb
View file @
e5ed2e4f
...
...
@@ -397,7 +397,7 @@ class NotificationService
end
def
relabeled_resource_email
(
target
,
labels
,
current_user
,
method
)
recipients
=
labels
.
flat_map
{
|
l
|
l
.
subscribers
(
target
.
project
)
}
recipients
=
labels
.
flat_map
{
|
l
|
l
.
subscribers
(
target
.
project
)
}
.
uniq
recipients
=
notifiable_users
(
recipients
,
:subscription
,
target:
target
,
...
...
spec/services/notification_service_spec.rb
View file @
e5ed2e4f
...
...
@@ -743,6 +743,18 @@ describe NotificationService, :mailer do
should_not_email
(
@u_participating
)
end
it
"doesn't send multiple email when a user is subscribed to multiple given labels"
do
subscriber_to_both
=
create
(
:user
)
do
|
user
|
[
label_1
,
label_2
].
each
{
|
label
|
label
.
toggle_subscription
(
user
,
project
)
}
end
notification
.
relabeled_issue
(
issue
,
[
label_1
,
label_2
],
@u_disabled
)
should_email
(
subscriber_to_label_1
)
should_email
(
subscriber_to_label_2
)
should_email
(
subscriber_to_both
)
end
context
'confidential issues'
do
let
(
:author
)
{
create
(
:user
)
}
let
(
:assignee
)
{
create
(
:user
)
}
...
...
spec/support/email_helpers.rb
View file @
e5ed2e4f
module
EmailHelpers
def
sent_to_user
?
(
user
,
recipients
=
email_recipients
)
recipients
.
include?
(
user
.
notification_email
)
def
sent_to_user
(
user
,
recipients:
email_recipients
)
recipients
.
count
{
|
to
|
to
==
user
.
notification_email
}
end
def
reset_delivered_emails!
...
...
@@ -10,17 +10,17 @@ module EmailHelpers
def
should_only_email
(
*
users
,
kind: :to
)
recipients
=
email_recipients
(
kind:
kind
)
users
.
each
{
|
user
|
should_email
(
user
,
recipients
)
}
users
.
each
{
|
user
|
should_email
(
user
,
recipients
:
recipients
)
}
expect
(
recipients
.
count
).
to
eq
(
users
.
count
)
end
def
should_email
(
user
,
recipients
=
email_recipients
)
expect
(
sent_to_user
?
(
user
,
recipients
)).
to
be_truthy
def
should_email
(
user
,
times:
1
,
recipients:
email_recipients
)
expect
(
sent_to_user
(
user
,
recipients:
recipients
)).
to
eq
(
times
)
end
def
should_not_email
(
user
,
recipients
=
email_recipients
)
expect
(
sent_to_user?
(
user
,
recipients
)).
to
be_falsey
def
should_not_email
(
user
,
recipients
:
email_recipients
)
should_email
(
user
,
times:
0
)
end
def
should_not_email_anyone
...
...
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