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
ffd7311d
Commit
ffd7311d
authored
Aug 16, 2016
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up the additions to notification_service_spec.rb
parent
0e9c4a90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
46 deletions
+28
-46
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+28
-46
No files found.
spec/services/notification_service_spec.rb
View file @
ffd7311d
...
@@ -9,6 +9,28 @@ describe NotificationService, services: true do
...
@@ -9,6 +9,28 @@ describe NotificationService, services: true do
end
end
end
end
shared_examples
'notifications for new mentions'
do
def
send_notifications
(
*
new_mentions
)
reset_delivered_emails!
notification
.
send
(
notification_method
,
mentionable
,
new_mentions
,
@u_disabled
)
end
it
'sends no emails when no new mentions are present'
do
send_notifications
expect
(
ActionMailer
::
Base
.
deliveries
).
to
be_empty
end
it
'emails new mentions with a watch level higher than participant'
do
send_notifications
(
@u_watcher
,
@u_participant_mentioned
,
@u_custom_global
)
should_only_email
(
@u_watcher
,
@u_participant_mentioned
,
@u_custom_global
)
end
it
'does not email new mentions with a watch level equal to or less than participant'
do
send_notifications
(
@u_participating
,
@u_mentioned
)
expect
(
ActionMailer
::
Base
.
deliveries
).
to
be_empty
end
end
describe
'Keys'
do
describe
'Keys'
do
describe
'#new_key'
do
describe
'#new_key'
do
let!
(
:key
)
{
create
(
:personal_key
)
}
let!
(
:key
)
{
create
(
:personal_key
)
}
...
@@ -400,30 +422,10 @@ describe NotificationService, services: true do
...
@@ -400,30 +422,10 @@ describe NotificationService, services: true do
end
end
describe
'#new_mentions_in_issue'
do
describe
'#new_mentions_in_issue'
do
def
send_notifications
(
*
new_mentions
)
let
(
:notification_method
)
{
:new_mentions_in_issue
}
ActionMailer
::
Base
.
deliveries
.
clear
let
(
:mentionable
)
{
issue
}
notification
.
new_mentions_in_issue
(
issue
,
new_mentions
,
@u_disabled
)
end
it
'sends no emails when no new mentions are present'
do
send_notifications
expect
(
ActionMailer
::
Base
.
deliveries
).
to
be_empty
end
it
'emails new mentions with a watch level higher than participant'
do
include_examples
'notifications for new mentions'
send_notifications
(
@u_watcher
,
@u_participant_mentioned
,
@u_custom_global
)
should_email
(
@u_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_custom_global
)
expect
(
ActionMailer
::
Base
.
deliveries
.
count
).
to
eq
3
end
it
'does not email new mentions with a watch level equal to or less than participant'
do
send_notifications
(
@u_participating
,
@u_mentioned
)
expect
(
ActionMailer
::
Base
.
deliveries
).
to
be_empty
end
end
end
describe
'#reassigned_issue'
do
describe
'#reassigned_issue'
do
...
@@ -793,30 +795,10 @@ describe NotificationService, services: true do
...
@@ -793,30 +795,10 @@ describe NotificationService, services: true do
end
end
describe
'#new_mentions_in_merge_request'
do
describe
'#new_mentions_in_merge_request'
do
def
send_notifications
(
*
new_mentions
)
let
(
:notification_method
)
{
:new_mentions_in_merge_request
}
ActionMailer
::
Base
.
deliveries
.
clear
let
(
:mentionable
)
{
merge_request
}
notification
.
new_mentions_in_merge_request
(
merge_request
,
new_mentions
,
@u_disabled
)
end
it
'sends no emails when there are no new mentions'
do
send_notifications
expect
(
ActionMailer
::
Base
.
deliveries
).
to
be_empty
end
it
'emails new mentions with a watch level higher than participant'
do
include_examples
'notifications for new mentions'
send_notifications
(
@u_watcher
,
@u_participant_mentioned
,
@u_custom_global
)
should_email
(
@u_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@u_custom_global
)
expect
(
ActionMailer
::
Base
.
deliveries
.
count
).
to
eq
3
end
it
'does not email new mentions with a watch level equal to or less than participant'
do
send_notifications
(
@u_participating
,
@u_mentioned
)
expect
(
ActionMailer
::
Base
.
deliveries
).
to
be_empty
end
end
end
describe
'#reassigned_merge_request'
do
describe
'#reassigned_merge_request'
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