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
e79b867d
Commit
e79b867d
authored
Apr 05, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure empty recipients are rejected in BuildsEmailService
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
1749bd3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
CHANGELOG
CHANGELOG
+1
-0
app/models/project_services/builds_email_service.rb
app/models/project_services/builds_email_service.rb
+7
-4
spec/models/project_services/builds_email_service_spec.rb
spec/models/project_services/builds_email_service_spec.rb
+22
-2
No files found.
CHANGELOG
View file @
e79b867d
...
...
@@ -14,6 +14,7 @@ v 8.7.0 (unreleased)
- Add links to CI setup documentation from project settings and builds pages
- Handle nil descriptions in Slack issue messages (Stan Hu)
- Add default scope to projects to exclude projects pending deletion
- Ensure empty recipients are rejected in BuildsEmailService
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
...
...
app/models/project_services/builds_email_service.rb
View file @
e79b867d
...
...
@@ -50,12 +50,15 @@ class BuildsEmailService < Service
def
execute
(
push_data
)
return
unless
supported_events
.
include?
(
push_data
[
:object_kind
])
return
unless
should_build_be_notified?
(
push_data
)
if
should_build_be_notified?
(
push_data
)
recipients
=
all_recipients
(
push_data
)
if
recipients
.
any?
BuildEmailWorker
.
perform_async
(
push_data
[
:build_id
],
all_recipients
(
push_data
)
,
push_data
,
recipients
,
push_data
)
end
end
...
...
@@ -84,7 +87,7 @@ class BuildsEmailService < Service
end
def
all_recipients
(
data
)
all_recipients
=
recipients
.
split
(
','
)
all_recipients
=
recipients
.
split
(
','
)
.
compact
.
reject
(
&
:blank?
)
if
add_pusher?
&&
data
[
:user
][
:email
]
all_recipients
<<
"
#{
data
[
:user
][
:email
]
}
"
...
...
spec/models/project_services/builds_email_service_spec.rb
View file @
e79b867d
...
...
@@ -6,18 +6,38 @@ describe BuildsEmailService do
let
(
:service
)
{
BuildsEmailService
.
new
}
describe
:execute
do
it
"sends email"
do
it
'sends email'
do
service
.
recipients
=
'test@gitlab.com'
data
[
:build_status
]
=
'failed'
expect
(
BuildEmailWorker
).
to
receive
(
:perform_async
)
service
.
execute
(
data
)
end
it
"does not sends email with failed build and allowed_failure on"
do
it
'does not send email with succeeded build and notify_only_broken_builds on'
do
expect
(
service
).
to
receive
(
:notify_only_broken_builds
).
and_return
(
true
)
data
[
:build_status
]
=
'success'
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
(
data
)
end
it
'does not send email with failed build and build_allow_failure is true'
do
data
[
:build_status
]
=
'failed'
data
[
:build_allow_failure
]
=
true
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
(
data
)
end
it
'does not send email with unknown build status'
do
data
[
:build_status
]
=
'foo'
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
(
data
)
end
it
'does not send email when recipients list is empty'
do
service
.
recipients
=
' ,, '
data
[
:build_status
]
=
'failed'
expect
(
BuildEmailWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
(
data
)
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