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
Boxiang Sun
gitlab-ce
Commits
ef5235cb
Commit
ef5235cb
authored
Jun 12, 2019
by
Eugenia Grieff
Committed by
Nick Thomas
Jun 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Email notifications do not work properly (issue due date)"
parent
14fef151
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
241 additions
and
2 deletions
+241
-2
app/models/notification_recipient.rb
app/models/notification_recipient.rb
+3
-2
changelogs/unreleased/58433-email-notifications-do-not-work-properly-issue-due-date.yml
...ail-notifications-do-not-work-properly-issue-due-date.yml
+5
-0
spec/models/notification_recipient_spec.rb
spec/models/notification_recipient_spec.rb
+233
-0
No files found.
app/models/notification_recipient.rb
View file @
ef5235cb
...
@@ -101,6 +101,7 @@ class NotificationRecipient
...
@@ -101,6 +101,7 @@ class NotificationRecipient
end
end
def
excluded_watcher_action?
def
excluded_watcher_action?
return
false
unless
@type
==
:watch
return
false
unless
@custom_action
return
false
unless
@custom_action
NotificationSetting
::
EXCLUDED_WATCHER_EVENTS
.
include?
(
@custom_action
)
NotificationSetting
::
EXCLUDED_WATCHER_EVENTS
.
include?
(
@custom_action
)
...
@@ -140,7 +141,7 @@ class NotificationRecipient
...
@@ -140,7 +141,7 @@ class NotificationRecipient
return
project_setting
unless
project_setting
.
nil?
||
project_setting
.
global?
return
project_setting
unless
project_setting
.
nil?
||
project_setting
.
global?
group_setting
=
closest_non_global_group_notification_sett
t
ing
group_setting
=
closest_non_global_group_notification_setting
return
group_setting
unless
group_setting
.
nil?
return
group_setting
unless
group_setting
.
nil?
...
@@ -148,7 +149,7 @@ class NotificationRecipient
...
@@ -148,7 +149,7 @@ class NotificationRecipient
end
end
# Returns the notification_setting of the lowest group in hierarchy with non global level
# Returns the notification_setting of the lowest group in hierarchy with non global level
def
closest_non_global_group_notification_sett
t
ing
def
closest_non_global_group_notification_setting
return
unless
@group
return
unless
@group
@group
@group
...
...
changelogs/unreleased/58433-email-notifications-do-not-work-properly-issue-due-date.yml
0 → 100644
View file @
ef5235cb
---
title
:
Fix email notifications for user excluded actions
merge_request
:
28835
author
:
type
:
fixed
spec/models/notification_recipient_spec.rb
View file @
ef5235cb
...
@@ -91,4 +91,237 @@ describe NotificationRecipient do
...
@@ -91,4 +91,237 @@ describe NotificationRecipient do
end
end
end
end
end
end
describe
'#suitable_notification_level?'
do
context
'when notification level is mention'
do
before
do
user
.
notification_settings_for
(
project
).
mention!
end
context
'when type is mention'
do
let
(
:recipient
)
{
described_class
.
new
(
user
,
:mention
,
target:
target
,
project:
project
)
}
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
'when type is not mention'
do
it
'returns false'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
false
end
end
end
context
'when notification level is participating'
do
let
(
:notification_setting
)
{
user
.
notification_settings_for
(
project
)
}
context
'when type is participating'
do
let
(
:recipient
)
{
described_class
.
new
(
user
,
:participating
,
target:
target
,
project:
project
)
}
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
'when type is mention'
do
let
(
:recipient
)
{
described_class
.
new
(
user
,
:mention
,
target:
target
,
project:
project
)
}
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
'with custom action'
do
context
"when action is failed_pipeline"
do
let
(
:recipient
)
do
described_class
.
new
(
user
,
:watch
,
custom_action: :failed_pipeline
,
target:
target
,
project:
project
)
end
before
do
notification_setting
.
update!
(
failed_pipeline:
true
)
end
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
"when action is not failed_pipeline"
do
let
(
:recipient
)
do
described_class
.
new
(
user
,
:watch
,
custom_action: :success_pipeline
,
target:
target
,
project:
project
)
end
before
do
notification_setting
.
update!
(
success_pipeline:
true
)
end
it
'returns false'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
false
end
end
end
end
context
'when notification level is custom'
do
before
do
user
.
notification_settings_for
(
project
).
custom!
end
context
'when type is participating'
do
let
(
:notification_setting
)
{
user
.
notification_settings_for
(
project
)
}
let
(
:recipient
)
do
described_class
.
new
(
user
,
:participating
,
custom_action: :new_note
,
target:
target
,
project:
project
)
end
context
'with custom event enabled'
do
before
do
notification_setting
.
update!
(
new_note:
true
)
end
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
'without custom event enabled'
do
before
do
notification_setting
.
update!
(
new_note:
false
)
end
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
end
context
'when type is mention'
do
let
(
:notification_setting
)
{
user
.
notification_settings_for
(
project
)
}
let
(
:recipient
)
do
described_class
.
new
(
user
,
:mention
,
custom_action: :new_issue
,
target:
target
,
project:
project
)
end
context
'with custom event enabled'
do
before
do
notification_setting
.
update!
(
new_issue:
true
)
end
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
'without custom event enabled'
do
before
do
notification_setting
.
update!
(
new_issue:
false
)
end
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
end
context
'when type is watch'
do
let
(
:notification_setting
)
{
user
.
notification_settings_for
(
project
)
}
let
(
:recipient
)
do
described_class
.
new
(
user
,
:watch
,
custom_action: :failed_pipeline
,
target:
target
,
project:
project
)
end
context
'with custom event enabled'
do
before
do
notification_setting
.
update!
(
failed_pipeline:
true
)
end
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
'without custom event enabled'
do
before
do
notification_setting
.
update!
(
failed_pipeline:
false
)
end
it
'returns false'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
false
end
end
end
end
context
'when notification level is watch'
do
before
do
user
.
notification_settings_for
(
project
).
watch!
end
context
'when type is watch'
do
context
'without excluded watcher events'
do
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
'with excluded watcher events'
do
let
(
:recipient
)
do
described_class
.
new
(
user
,
:watch
,
custom_action: :issue_due
,
target:
target
,
project:
project
)
end
it
'returns false'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
false
end
end
end
context
'when type is not watch'
do
context
'without excluded watcher events'
do
let
(
:recipient
)
{
described_class
.
new
(
user
,
:participating
,
target:
target
,
project:
project
)
}
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
end
end
context
'with excluded watcher events'
do
let
(
:recipient
)
do
described_class
.
new
(
user
,
:participating
,
custom_action: :issue_due
,
target:
target
,
project:
project
)
end
it
'returns true'
do
expect
(
recipient
.
suitable_notification_level?
).
to
eq
true
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