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
8ee04ebe
Commit
8ee04ebe
authored
Apr 14, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patch-1' into 'master'
Do not require recipients when pusher will be recipient Closes #10946 See merge request !3603
parents
a872a29e
2fd05aed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
5 deletions
+43
-5
CHANGELOG
CHANGELOG
+1
-0
builds_email_service.rb
app/models/project_services/builds_email_service.rb
+7
-3
builds_email_service_spec.rb
spec/models/project_services/builds_email_service_spec.rb
+35
-2
No files found.
CHANGELOG
View file @
8ee04ebe
...
...
@@ -60,6 +60,7 @@ v 8.7.0 (unreleased)
- API: Expose 'updated_at' for issue, snippet, and merge request notes (Robert Schilling)
- API: User can leave a project through the API when not master or owner. !3613
- Fix repository cache invalidation issue when project is recreated with an empty repo (Stan Hu)
- Fix: Allow empty recipients list for builds emails service when pushed is added (Frank Groeneveld)
v 8.6.6
- Fix error on language detection when repository has no HEAD (e.g., master branch). !3654 (Jeroen Bobbeldijk)
...
...
app/models/project_services/builds_email_service.rb
View file @
8ee04ebe
...
...
@@ -23,7 +23,7 @@ class BuildsEmailService < Service
prop_accessor
:recipients
boolean_accessor
:add_pusher
boolean_accessor
:notify_only_broken_builds
validates
:recipients
,
presence:
true
,
if:
:activated?
validates
:recipients
,
presence:
true
,
if:
->
(
s
)
{
s
.
activated?
&&
!
s
.
add_pusher?
}
def
initialize_properties
if
properties
.
nil?
...
...
@@ -87,10 +87,14 @@ class BuildsEmailService < Service
end
def
all_recipients
(
data
)
all_recipients
=
recipients
.
split
(
','
).
compact
.
reject
(
&
:blank?
)
all_recipients
=
[]
unless
recipients
.
blank?
all_recipients
+=
recipients
.
split
(
','
).
compact
.
reject
(
&
:blank?
)
end
if
add_pusher?
&&
data
[
:user
][
:email
]
all_recipients
<<
"
#{
data
[
:user
][
:email
]
}
"
all_recipients
<<
data
[
:user
][
:email
]
end
all_recipients
...
...
spec/models/project_services/builds_email_service_spec.rb
View file @
8ee04ebe
...
...
@@ -3,9 +3,10 @@ require 'spec_helper'
describe
BuildsEmailService
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:data
)
{
Gitlab
::
BuildDataBuilder
.
build
(
build
)
}
let
(
:service
)
{
BuildsEmailService
.
new
}
let!
(
:project
)
{
create
(
:project
,
:public
,
ci_id:
1
)
}
let
(
:service
)
{
described_class
.
new
(
project:
project
,
active:
true
)
}
describe
:execute
do
describe
'#execute'
do
it
'sends email'
do
service
.
recipients
=
'test@gitlab.com'
data
[
:build_status
]
=
'failed'
...
...
@@ -40,4 +41,36 @@ describe BuildsEmailService do
service
.
execute
(
data
)
end
end
describe
'validations'
do
context
'when pusher is not added'
do
before
{
service
.
add_pusher
=
false
}
it
'does not allow empty recipient input'
do
service
.
recipients
=
''
expect
(
service
.
valid?
).
to
be
false
end
it
'does allow non-empty recipient input'
do
service
.
recipients
=
'test@example.com'
expect
(
service
.
valid?
).
to
be
true
end
end
context
'when pusher is added'
do
before
{
service
.
add_pusher
=
true
}
it
'does allow empty recipient input'
do
service
.
recipients
=
''
expect
(
service
.
valid?
).
to
be
true
end
it
'does allow non-empty recipient input'
do
service
.
recipients
=
'test@example.com'
expect
(
service
.
valid?
).
to
be
true
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