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
7f7c3e1a
Commit
7f7c3e1a
authored
Sep 14, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add notification tests for it
parent
09a7da72
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
6 deletions
+61
-6
spec/services/ci/send_pipeline_notification_service_spec.rb
spec/services/ci/send_pipeline_notification_service_spec.rb
+61
-6
No files found.
spec/services/ci/send_pipeline_notification_service_spec.rb
View file @
7f7c3e1a
...
...
@@ -11,23 +11,30 @@ describe Ci::SendPipelineNotificationService, services: true do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
described_class
.
new
(
pipeline
)
}
let
(
:pusher
)
{
user
}
let
(
:watcher
)
{
pusher
}
describe
'#execute'
do
before
do
reset_delivered_emails!
pipeline
.
project
.
team
<<
[
watcher
,
Gitlab
::
Access
::
DEVELOPER
]
end
shared_examples
'sending emails'
do
it
'sends
an email to pipeline user
'
do
it
'sends
emails
'
do
perform_enqueued_jobs
do
subject
.
execute
([
user
.
email
])
end
email
=
ActionMailer
::
Base
.
deliveries
.
last
expected_receivers
=
[
pusher
,
watcher
].
uniq
.
sort_by
(
&
:email
)
actual
=
ActionMailer
::
Base
.
deliveries
.
sort_by
(
&
:to
)
expect
(
expected_receivers
.
size
).
to
eq
(
actual
.
size
)
actual
.
zip
(
expected_receivers
).
each
do
|
(
email
,
receiver
)
|
expect
(
email
.
subject
).
to
include
(
email_subject
)
expect
(
email
.
to
).
to
eq
([
user
.
email
])
expect
(
email
.
to
).
to
eq
([
receiver
.
email
])
end
end
end
...
...
@@ -36,6 +43,30 @@ describe Ci::SendPipelineNotificationService, services: true do
let
(
:email_subject
)
{
"Pipeline #
#{
pipeline
.
id
}
has succeeded"
}
it_behaves_like
'sending emails'
context
'with pipeline from someone else'
do
let
(
:pusher
)
{
create
(
:user
)
}
context
'with success pipeline notification on'
do
let
(
:watcher
)
{
user
}
before
do
watcher
.
global_notification_setting
.
update
(
level:
'custom'
,
success_pipeline:
true
)
end
it_behaves_like
'sending emails'
end
context
'with success pipeline notification off'
do
before
do
watcher
.
global_notification_setting
.
update
(
level:
'custom'
,
success_pipeline:
false
)
end
it_behaves_like
'sending emails'
end
end
end
context
'with failed pipeline'
do
...
...
@@ -43,6 +74,30 @@ describe Ci::SendPipelineNotificationService, services: true do
let
(
:email_subject
)
{
"Pipeline #
#{
pipeline
.
id
}
has failed"
}
it_behaves_like
'sending emails'
context
'with pipeline from someone else'
do
let
(
:pusher
)
{
create
(
:user
)
}
context
'with failed pipeline notification on'
do
let
(
:watcher
)
{
user
}
before
do
watcher
.
global_notification_setting
.
update
(
level:
'custom'
,
failed_pipeline:
true
)
end
it_behaves_like
'sending emails'
end
context
'with failed pipeline notification off'
do
before
do
watcher
.
global_notification_setting
.
update
(
level:
'custom'
,
failed_pipeline:
false
)
end
it_behaves_like
'sending emails'
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