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
c215c6f6
Commit
c215c6f6
authored
Jan 30, 2020
by
David Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a shared example for handling Gitaly exceptions
parent
2d9fa318
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
22 deletions
+19
-22
spec/helpers/avatars_helper_spec.rb
spec/helpers/avatars_helper_spec.rb
+19
-22
No files found.
spec/helpers/avatars_helper_spec.rb
View file @
c215c6f6
...
@@ -22,6 +22,21 @@ describe AvatarsHelper do
...
@@ -22,6 +22,21 @@ describe AvatarsHelper do
end
end
end
end
shared_examples
'Gitaly exception handling'
do
before
do
allow
(
resource
).
to
receive
(
:avatar_url
).
and_raise
(
error_class
)
end
it
'handles Gitaly exception gracefully'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
).
with
(
an_instance_of
(
error_class
),
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 providing a project'
do
context
'when providing a project'
do
let
(
:helper_args
)
{
[
resource
]
}
let
(
:helper_args
)
{
[
resource
]
}
let
(
:resource
)
{
create
(
:project
,
name:
'foo'
)
}
let
(
:resource
)
{
create
(
:project
,
name:
'foo'
)
}
...
@@ -33,33 +48,15 @@ describe AvatarsHelper do
...
@@ -33,33 +48,15 @@ describe AvatarsHelper do
end
end
context
'when Gitaly is unavailable'
do
context
'when Gitaly is unavailable'
do
before
do
let
(
:error_class
)
{
GRPC
::
Unavailable
}
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
i
t_behaves_like
'resource with a default avatar'
,
'project
'
i
nclude_examples
'Gitaly exception handling
'
end
end
context
'when Gitaly request is taking too long'
do
context
'when Gitaly request is taking too long'
do
before
do
let
(
:error_class
)
{
GRPC
::
DeadlineExceeded
}
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
i
t_behaves_like
'resource with a default avatar'
,
'project
'
i
nclude_examples
'Gitaly exception handling
'
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