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
c9f202b2
Commit
c9f202b2
authored
Feb 11, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken link in CI build notification emails
Closes #13199
parent
b1dda814
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
46 deletions
+50
-46
app/mailers/emails/builds.rb
app/mailers/emails/builds.rb
+7
-6
app/views/notify/build_fail_email.html.haml
app/views/notify/build_fail_email.html.haml
+2
-1
app/views/notify/build_success_email.html.haml
app/views/notify/build_success_email.html.haml
+1
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+40
-38
No files found.
app/mailers/emails/builds.rb
View file @
c9f202b2
...
@@ -3,26 +3,27 @@ module Emails
...
@@ -3,26 +3,27 @@ module Emails
def
build_fail_email
(
build_id
,
to
)
def
build_fail_email
(
build_id
,
to
)
@build
=
Ci
::
Build
.
find
(
build_id
)
@build
=
Ci
::
Build
.
find
(
build_id
)
@project
=
@build
.
project
@project
=
@build
.
project
add_project_headers
add_project_headers
add_build_headers
add_build_headers
(
'failed'
)
headers
[
'X-GitLab-Build-Status'
]
=
"failed"
mail
(
to:
to
,
subject:
subject
(
"Build failed for
#{
@project
.
name
}
"
,
@build
.
short_sha
))
mail
(
to:
to
,
subject:
subject
(
"Build failed for
#{
@project
.
name
}
"
,
@build
.
short_sha
))
end
end
def
build_success_email
(
build_id
,
to
)
def
build_success_email
(
build_id
,
to
)
@build
=
Ci
::
Build
.
find
(
build_id
)
@build
=
Ci
::
Build
.
find
(
build_id
)
@project
=
@build
.
project
@project
=
@build
.
project
add_project_headers
add_project_headers
add_build_headers
add_build_headers
(
'success'
)
headers
[
'X-GitLab-Build-Status'
]
=
"success"
mail
(
to:
to
,
subject:
subject
(
"Build success for
#{
@project
.
name
}
"
,
@build
.
short_sha
))
mail
(
to:
to
,
subject:
subject
(
"Build success for
#{
@project
.
name
}
"
,
@build
.
short_sha
))
end
end
private
private
def
add_build_headers
def
add_build_headers
(
status
)
headers
[
'X-GitLab-Build-Id'
]
=
@build
.
id
headers
[
'X-GitLab-Build-Id'
]
=
@build
.
id
headers
[
'X-GitLab-Build-Ref'
]
=
@build
.
ref
headers
[
'X-GitLab-Build-Ref'
]
=
@build
.
ref
headers
[
'X-GitLab-Build-Status'
]
=
status
.
to_s
end
end
end
end
end
end
app/views/notify/build_fail_email.html.haml
View file @
c9f202b2
-
content_for
:header
do
-
content_for
:header
do
%h1
{
style:
"background: #c40834; color: #FFF; font: normal 20px Helvetica, Arial, sans-serif; margin: 0; padding: 5px 10px; line-height: 32px; font-size: 16px;"
}
%h1
{
style:
"background: #c40834; color: #FFF; font: normal 20px Helvetica, Arial, sans-serif; margin: 0; padding: 5px 10px; line-height: 32px; font-size: 16px;"
}
GitLab (build failed)
GitLab (build failed)
%h3
%h3
Project:
Project:
=
link_to
ci_project_url
(
@project
)
do
=
link_to
namespace_project_url
(
@project
.
namespace
,
@project
)
do
=
@project
.
name
=
@project
.
name
%p
%p
...
...
app/views/notify/build_success_email.html.haml
View file @
c9f202b2
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
%h3
%h3
Project:
Project:
=
link_to
ci_project_url
(
@project
)
do
=
link_to
namespace_project_url
(
@project
.
namespace
,
@project
)
do
=
@project
.
name
=
@project
.
name
%p
%p
...
...
spec/mailers/notify_spec.rb
View file @
c9f202b2
...
@@ -13,7 +13,6 @@ describe Notify do
...
@@ -13,7 +13,6 @@ describe Notify do
let
(
:gitlab_sender_reply_to
)
{
Gitlab
.
config
.
gitlab
.
email_reply_to
}
let
(
:gitlab_sender_reply_to
)
{
Gitlab
.
config
.
gitlab
.
email_reply_to
}
let
(
:recipient
)
{
create
(
:user
,
email:
'recipient@example.com'
)
}
let
(
:recipient
)
{
create
(
:user
,
email:
'recipient@example.com'
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:build
)
{
create
(
:ci_build
)
}
before
(
:each
)
do
before
(
:each
)
do
ActionMailer
::
Base
.
deliveries
.
clear
ActionMailer
::
Base
.
deliveries
.
clear
...
@@ -48,13 +47,6 @@ describe Notify do
...
@@ -48,13 +47,6 @@ describe Notify do
end
end
end
end
shared_examples
'an email with X-GitLab headers containing build details'
do
it
'has X-GitLab-Build* headers'
do
is_expected
.
to
have_header
'X-GitLab-Build-Id'
,
/
#{
build
.
id
}
/
is_expected
.
to
have_header
'X-GitLab-Build-Ref'
,
/
#{
build
.
ref
}
/
end
end
shared_examples
'an email that contains a header with author username'
do
shared_examples
'an email that contains a header with author username'
do
it
'has X-GitLab-Author header containing author\'s username'
do
it
'has X-GitLab-Author header containing author\'s username'
do
is_expected
.
to
have_header
'X-GitLab-Author'
,
user
.
username
is_expected
.
to
have_header
'X-GitLab-Author'
,
user
.
username
...
@@ -971,49 +963,59 @@ describe Notify do
...
@@ -971,49 +963,59 @@ describe Notify do
end
end
end
end
describe
'build success'
do
describe
'build notification email'
do
before
{
build
.
success
}
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:project
)
{
build
.
project
}
subject
{
Notify
.
build_success_email
(
build
.
id
,
'wow@example.com'
)
}
shared_examples
'build email'
do
it
'contains name of project'
do
it_behaves_like
'an email with X-GitLab headers containing build details'
is_expected
.
to
have_body_text
build
.
project_name
it_behaves_like
'an email with X-GitLab headers containing project details'
do
end
let
(
:project
)
{
build
.
project
}
end
it
'has header indicating build status'
do
it
'contains link to project'
do
is_expected
.
to
have_header
'X-GitLab-Build-Status'
,
'success'
is_expected
.
to
have_body_text
namespace_project_path
(
project
.
namespace
,
project
)
end
end
end
it
'has the correct subject'
do
shared_examples
'an email with X-GitLab headers containing build details'
do
should
have_subject
/Build success for/
it
'has X-GitLab-Build* headers'
do
is_expected
.
to
have_header
'X-GitLab-Build-Id'
,
/
#{
build
.
id
}
/
is_expected
.
to
have_header
'X-GitLab-Build-Ref'
,
/
#{
build
.
ref
}
/
end
end
end
it
'contains name of project'
do
describe
'build success'
do
should
have_body_text
build
.
project_name
subject
{
Notify
.
build_success_email
(
build
.
id
,
'wow@example.com'
)
}
end
before
{
build
.
success
}
end
describe
'build fail'
do
it_behaves_like
'build email'
before
{
build
.
drop
}
it_behaves_like
'an email with X-GitLab headers containing build details'
it_behaves_like
'an email with X-GitLab headers containing project details'
subject
{
Notify
.
build_fail_email
(
build
.
id
,
'wow@example.com'
)
}
it
'has header indicating build status'
do
is_expected
.
to
have_header
'X-GitLab-Build-Status'
,
'success'
end
it_behaves_like
'an email with X-GitLab headers containing build details'
it
'has the correct subject'
do
it_behaves_like
'an email with X-GitLab headers containing project details'
do
is_expected
.
to
have_subject
/Build success for/
let
(
:project
)
{
build
.
project
}
end
end
end
it
'has header indicating build status
'
do
describe
'build fail
'
do
is_expected
.
to
have_header
'X-GitLab-Build-Status'
,
'failed'
subject
{
Notify
.
build_fail_email
(
build
.
id
,
'wow@example.com'
)
}
end
before
{
build
.
drop
}
it
'has the correct subject'
do
it_behaves_like
'build email'
should
have_subject
/Build failed for/
it_behaves_like
'an email with X-GitLab headers containing build details'
end
it_behaves_like
'an email with X-GitLab headers containing project details'
it
'contains name of project'
do
it
'has header indicating build status'
do
should
have_body_text
build
.
project_name
is_expected
.
to
have_header
'X-GitLab-Build-Status'
,
'failed'
end
it
'has the correct subject'
do
is_expected
.
to
have_subject
/Build failed for/
end
end
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