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
c2e6bb8e
Commit
c2e6bb8e
authored
Jan 29, 2020
by
David Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fallback to default project icon when Gitaly is not responding
parent
a15388de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
5 deletions
+41
-5
app/helpers/avatars_helper.rb
app/helpers/avatars_helper.rb
+7
-0
spec/helpers/avatars_helper_spec.rb
spec/helpers/avatars_helper_spec.rb
+34
-5
No files found.
app/helpers/avatars_helper.rb
View file @
c2e6bb8e
...
...
@@ -122,6 +122,13 @@ module AvatarsHelper
else
source_identicon
(
source
,
options
)
end
rescue
GRPC
::
Unavailable
,
GRPC
::
DeadlineExceeded
=>
e
# Handle Gitaly connection issues gracefully
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
source_type:
source
.
class
.
name
,
source_id:
source
.
id
)
source_identicon
(
source
,
options
)
end
def
source_identicon
(
source
,
options
=
{})
...
...
spec/helpers/avatars_helper_spec.rb
View file @
c2e6bb8e
...
...
@@ -23,14 +23,43 @@ describe AvatarsHelper do
end
context
'when providing a project'
do
it_behaves_like
'resource with a default avatar'
,
'project'
do
let
(
:resource
)
{
create
(
:project
,
name:
'foo'
)
}
let
(
:helper_args
)
{
[
resource
]
}
end
let
(
:helper_args
)
{
[
resource
]
}
let
(
:resource
)
{
create
(
:project
,
name:
'foo'
)
}
it_behaves_like
'resource with a default avatar'
,
'project'
it_behaves_like
'resource with a custom avatar'
,
'project'
do
let
(
:resource
)
{
create
(
:project
,
:public
,
avatar:
File
.
open
(
uploaded_image_temp_path
))
}
let
(
:helper_args
)
{
[
resource
]
}
end
context
'when Gitaly is unavailable'
do
before
do
allow
(
resource
).
to
receive
(
:avatar_url
).
and_raise
(
GRPC
::
Unavailable
)
end
it
'handles Gitaly unavailable exceptions gracefully'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
).
with
(
an_instance_of
(
GRPC
::
Unavailable
),
source_type:
'Project'
,
source_id:
resource
.
id
)
expect
{
project_icon
(
resource
)
}.
not_to
raise_error
end
it_behaves_like
'resource with a default avatar'
,
'project'
end
context
'when Gitaly request is taking too long'
do
before
do
allow
(
resource
).
to
receive
(
:avatar_url
).
and_raise
(
GRPC
::
DeadlineExceeded
)
end
it
'handles Gitaly timeout exceptions gracefully'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
).
with
(
an_instance_of
(
GRPC
::
DeadlineExceeded
),
source_type:
'Project'
,
source_id:
resource
.
id
)
expect
{
project_icon
(
resource
)
}.
not_to
raise_error
end
it_behaves_like
'resource with a default avatar'
,
'project'
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