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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
02f866cc
Commit
02f866cc
authored
Jun 20, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix avatar images in pipeline and approval emails
parent
27ca209c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
42 deletions
+71
-42
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+2
-2
app/views/notify/approved_merge_request_email.html.haml
app/views/notify/approved_merge_request_email.html.haml
+3
-3
app/views/notify/pipeline_failed_email.html.haml
app/views/notify/pipeline_failed_email.html.haml
+3
-3
app/views/notify/pipeline_success_email.html.haml
app/views/notify/pipeline_success_email.html.haml
+3
-3
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+60
-31
No files found.
app/helpers/application_helper.rb
View file @
02f866cc
...
@@ -68,7 +68,7 @@ module ApplicationHelper
...
@@ -68,7 +68,7 @@ module ApplicationHelper
end
end
end
end
def
avatar_icon
(
user_or_email
=
nil
,
size
=
nil
,
scale
=
2
)
def
avatar_icon
(
user_or_email
=
nil
,
size
=
nil
,
scale
=
2
,
only_path:
true
)
user
=
user
=
if
user_or_email
.
is_a?
(
User
)
if
user_or_email
.
is_a?
(
User
)
user_or_email
user_or_email
...
@@ -77,7 +77,7 @@ module ApplicationHelper
...
@@ -77,7 +77,7 @@ module ApplicationHelper
end
end
if
user
if
user
user
.
avatar_url
(
size:
size
)
||
default_avatar
user
.
avatar_url
(
size:
size
,
only_path:
only_path
)
||
default_avatar
else
else
gravatar_icon
(
user_or_email
,
size
,
scale
)
gravatar_icon
(
user_or_email
,
size
,
scale
)
end
end
...
...
app/views/notify/approved_merge_request_email.html.haml
View file @
02f866cc
...
@@ -79,7 +79,7 @@
...
@@ -79,7 +79,7 @@
%span
{
style:
"font-weight: bold;color:#333333;"
}
Merge request
%span
{
style:
"font-weight: bold;color:#333333;"
}
Merge request
%a
{
href:
merge_request_url
(
@merge_request
),
style:
"font-weight: bold;color:#3777b0;text-decoration:none"
}=
@merge_request
.
to_reference
%a
{
href:
merge_request_url
(
@merge_request
),
style:
"font-weight: bold;color:#3777b0;text-decoration:none"
}=
@merge_request
.
to_reference
%span
was approved by
%span
was approved by
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@approved_by
,
24
),
style:
"border-radius:12px;margin:-7px 0 -7px 3px;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@approved_by
,
24
,
only_path:
false
),
style:
"border-radius:12px;margin:-7px 0 -7px 3px;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%a
.muted
{
href:
user_url
(
@approved_by
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
@approved_by
),
style:
"color:#333333;text-decoration:none;"
}
=
@approved_by
.
name
=
@approved_by
.
name
%tr
.spacer
%tr
.spacer
...
@@ -117,7 +117,7 @@
...
@@ -117,7 +117,7 @@
%tbody
%tbody
%tr
%tr
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@merge_request
.
author
,
24
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@merge_request
.
author
,
24
,
only_path:
false
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
%a
.muted
{
href:
user_url
(
@merge_request
.
author
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
@merge_request
.
author
),
style:
"color:#333333;text-decoration:none;"
}
=
@merge_request
.
author
.
name
=
@merge_request
.
author
.
name
...
@@ -130,7 +130,7 @@
...
@@ -130,7 +130,7 @@
%tbody
%tbody
%tr
%tr
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@merge_request
.
assignee
,
24
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@merge_request
.
assignee
,
24
,
only_path:
false
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
%a
.muted
{
href:
user_url
(
@merge_request
.
assignee
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
@merge_request
.
assignee
),
style:
"color:#333333;text-decoration:none;"
}
=
@merge_request
.
assignee
.
name
=
@merge_request
.
assignee
.
name
...
...
app/views/notify/pipeline_failed_email.html.haml
View file @
02f866cc
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
%tbody
%tbody
%tr
%tr
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
commit
.
author
||
commit
.
author_email
,
24
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
commit
.
author
||
commit
.
author_email
,
24
,
only_path:
false
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
-
if
commit
.
author
-
if
commit
.
author
%a
.muted
{
href:
user_url
(
commit
.
author
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
commit
.
author
),
style:
"color:#333333;text-decoration:none;"
}
...
@@ -76,7 +76,7 @@
...
@@ -76,7 +76,7 @@
%tbody
%tbody
%tr
%tr
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
commit
.
committer
||
commit
.
committer_email
,
24
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
commit
.
committer
||
commit
.
committer_email
,
24
,
only_path:
false
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
-
if
commit
.
committer
-
if
commit
.
committer
%a
.muted
{
href:
user_url
(
commit
.
committer
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
commit
.
committer
),
style:
"color:#333333;text-decoration:none;"
}
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
triggered by
triggered by
-
if
@pipeline
.
user
-
if
@pipeline
.
user
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;padding-left:5px"
,
width:
"24"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;padding-left:5px"
,
width:
"24"
}
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@pipeline
.
user
,
24
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@pipeline
.
user
,
24
,
only_path:
false
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-weight:500;line-height:1.4;vertical-align:baseline;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-weight:500;line-height:1.4;vertical-align:baseline;"
}
%a
.muted
{
href:
user_url
(
@pipeline
.
user
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
@pipeline
.
user
),
style:
"color:#333333;text-decoration:none;"
}
=
@pipeline
.
user
.
name
=
@pipeline
.
user
.
name
...
...
app/views/notify/pipeline_success_email.html.haml
View file @
02f866cc
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
%tbody
%tbody
%tr
%tr
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
commit
.
author
||
commit
.
author_email
,
24
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
commit
.
author
||
commit
.
author_email
,
24
,
only_path:
false
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
-
if
commit
.
author
-
if
commit
.
author
%a
.muted
{
href:
user_url
(
commit
.
author
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
commit
.
author
),
style:
"color:#333333;text-decoration:none;"
}
...
@@ -76,7 +76,7 @@
...
@@ -76,7 +76,7 @@
%tbody
%tbody
%tr
%tr
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;"
}
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
commit
.
committer
||
commit
.
committer_email
,
24
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
commit
.
committer
||
commit
.
committer_email
,
24
,
only_path:
false
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;"
}
-
if
commit
.
committer
-
if
commit
.
committer
%a
.muted
{
href:
user_url
(
commit
.
committer
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
commit
.
committer
),
style:
"color:#333333;text-decoration:none;"
}
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
triggered by
triggered by
-
if
@pipeline
.
user
-
if
@pipeline
.
user
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;padding-left:5px"
,
width:
"24"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.4;vertical-align:middle;padding-right:5px;padding-left:5px"
,
width:
"24"
}
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@pipeline
.
user
,
24
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%img
.avatar
{
height:
"24"
,
src:
avatar_icon
(
@pipeline
.
user
,
24
,
only_path:
false
),
style:
"display:block;border-radius:12px;margin:-2px 0;"
,
width:
"24"
,
alt:
"Avatar"
}
/
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-weight:500;line-height:1.4;vertical-align:baseline;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-weight:500;line-height:1.4;vertical-align:baseline;"
}
%a
.muted
{
href:
user_url
(
@pipeline
.
user
),
style:
"color:#333333;text-decoration:none;"
}
%a
.muted
{
href:
user_url
(
@pipeline
.
user
),
style:
"color:#333333;text-decoration:none;"
}
=
@pipeline
.
user
.
name
=
@pipeline
.
user
.
name
...
...
spec/helpers/application_helper_spec.rb
View file @
02f866cc
...
@@ -82,42 +82,71 @@ describe ApplicationHelper do
...
@@ -82,42 +82,71 @@ describe ApplicationHelper do
end
end
describe
'avatar_icon'
do
describe
'avatar_icon'
do
it
'returns an url for the avatar'
do
let
(
:user
)
{
create
(
:user
,
avatar:
File
.
open
(
uploaded_image_temp_path
))
}
user
=
create
(
:user
,
avatar:
File
.
open
(
uploaded_image_temp_path
))
context
'using an email'
do
avatar_url
=
"/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
context
'when there is a matching user'
do
it
'returns a relative URL for the avatar'
do
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
to
match
(
avatar_url
)
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
to
eq
(
"/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
gitlab_host
)
end
avatar_url
=
"
#{
gitlab_host
}
/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
context
'when an asset_host is set in the config'
do
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
to
match
(
avatar_url
)
let
(
:asset_host
)
{
'http://assets'
}
end
before
do
it
'returns an url for the avatar with relative url'
do
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
asset_host
)
stub_config_setting
(
relative_url_root:
'/gitlab'
)
end
# Must be stubbed after the stub above, and separately
stub_config_setting
(
url:
Settings
.
send
(
:build_gitlab_url
))
it
'returns an absolute URL on that asset host'
do
expect
(
helper
.
avatar_icon
(
user
.
email
,
only_path:
false
).
to_s
).
user
=
create
(
:user
,
avatar:
File
.
open
(
uploaded_image_temp_path
))
to
eq
(
"
#{
asset_host
}
/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
end
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
end
to
match
(
"/gitlab/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
end
context
'when only_path is set to false'
do
it
'returns an absolute URL for the avatar'
do
expect
(
helper
.
avatar_icon
(
user
.
email
,
only_path:
false
).
to_s
).
to
eq
(
"
#{
gitlab_host
}
/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
end
end
context
'when the GitLab instance is at a relative URL'
do
before
do
stub_config_setting
(
relative_url_root:
'/gitlab'
)
# Must be stubbed after the stub above, and separately
stub_config_setting
(
url:
Settings
.
send
(
:build_gitlab_url
))
end
it
'returns a relative URL with the correct prefix'
do
expect
(
helper
.
avatar_icon
(
user
.
email
).
to_s
).
to
eq
(
"/gitlab/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
end
end
end
it
'calls gravatar_icon when no User exists with the given email'
do
context
'when no user exists for the email'
do
expect
(
helper
).
to
receive
(
:gravatar_icon
).
with
(
'foo@example.com'
,
20
,
2
)
it
'calls gravatar_icon'
do
expect
(
helper
).
to
receive
(
:gravatar_icon
).
with
(
'foo@example.com'
,
20
,
2
)
helper
.
avatar_icon
(
'foo@example.com'
,
20
,
2
)
helper
.
avatar_icon
(
'foo@example.com'
,
20
,
2
)
end
end
end
end
describe
'using a User'
do
describe
'using a user'
do
it
'returns an URL for the avatar'
do
context
'when only_path is true'
do
user
=
create
(
:user
,
avatar:
File
.
open
(
uploaded_image_temp_path
))
it
'returns a relative URL for the avatar'
do
expect
(
helper
.
avatar_icon
(
user
,
only_path:
true
).
to_s
).
to
eq
(
"/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
end
end
expect
(
helper
.
avatar_icon
(
user
).
to_s
).
context
'when only_path is false'
do
to
match
(
"/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
it
'returns an absolute URL for the avatar'
do
expect
(
helper
.
avatar_icon
(
user
,
only_path:
false
).
to_s
).
to
eq
(
"
#{
gitlab_host
}
/uploads/system/user/avatar/
#{
user
.
id
}
/banana_sample.gif"
)
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