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
5720bce1
Commit
5720bce1
authored
Sep 13, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also treat newlines as separator, as people would do that
Before this fix, I don't know if those emails would work having newlines in them.
parent
46bdcd64
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
14 deletions
+25
-14
pipelines_email_service.rb
app/models/project_services/pipelines_email_service.rb
+1
-1
pipelines_email_service_spec.rb
spec/models/project_services/pipelines_email_service_spec.rb
+24
-13
No files found.
app/models/project_services/pipelines_email_service.rb
View file @
5720bce1
...
...
@@ -80,6 +80,6 @@ class PipelinesEmailService < Service
end
def
retrieve_recipients
(
data
)
recipients
.
to_s
.
split
(
','
).
reject
(
&
:blank
?
)
recipients
.
to_s
.
split
(
/[,(?:\r?\n) ]+/
).
reject
(
&
:empty
?
)
end
end
spec/models/project_services/pipelines_email_service_spec.rb
View file @
5720bce1
...
...
@@ -6,7 +6,8 @@ describe PipelinesEmailService, :mailer do
end
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:recipient
)
{
'test@gitlab.com'
}
let
(
:recipients
)
{
'test@gitlab.com'
}
let
(
:receivers
)
{
[
recipients
]
}
let
(
:data
)
do
Gitlab
::
DataBuilder
::
Pipeline
.
build
(
pipeline
)
...
...
@@ -48,18 +49,24 @@ describe PipelinesEmailService, :mailer do
shared_examples
'sending email'
do
before
do
subject
.
recipients
=
recipients
perform_enqueued_jobs
do
run
end
end
it
'sends email'
do
should_only_email
(
double
(
notification_email:
recipient
),
kind: :bcc
)
emails
=
receivers
.
map
{
|
r
|
double
(
notification_email:
r
)
}
should_only_email
(
*
emails
,
kind: :bcc
)
end
end
shared_examples
'not sending email'
do
before
do
subject
.
recipients
=
recipients
perform_enqueued_jobs
do
run
end
...
...
@@ -75,10 +82,6 @@ describe PipelinesEmailService, :mailer do
subject
.
test
(
data
)
end
before
do
subject
.
recipients
=
recipient
end
context
'when pipeline is failed'
do
before
do
data
[
:object_attributes
][
:status
]
=
'failed'
...
...
@@ -104,10 +107,6 @@ describe PipelinesEmailService, :mailer do
end
context
'with recipients'
do
before
do
subject
.
recipients
=
recipient
end
context
'with failed pipeline'
do
before
do
data
[
:object_attributes
][
:status
]
=
'failed'
...
...
@@ -152,9 +151,7 @@ describe PipelinesEmailService, :mailer do
end
context
'with empty recipients list'
do
before
do
subject
.
recipients
=
' ,, '
end
let
(
:recipients
)
{
' ,, '
}
context
'with failed pipeline'
do
before
do
...
...
@@ -165,5 +162,19 @@ describe PipelinesEmailService, :mailer do
it_behaves_like
'not sending email'
end
end
context
'with recipients list separating with newlines'
do
let
(
:recipients
)
{
"
\n
test@gitlab.com,
\r\n
example@gitlab.com"
}
let
(
:receivers
)
{
%w[test@gitlab.com example@gitlab.com]
}
context
'with failed pipeline'
do
before
do
data
[
:object_attributes
][
:status
]
=
'failed'
pipeline
.
update
(
status:
'failed'
)
end
it_behaves_like
'sending email'
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