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
ddbc229d
Commit
ddbc229d
authored
Mar 09, 2021
by
Markus Koller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle RestClient errors in Discord integration
parent
cbd3726e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
app/models/project_services/discord_service.rb
app/models/project_services/discord_service.rb
+3
-0
changelogs/unreleased/321659-handle-discord-errors.yml
changelogs/unreleased/321659-handle-discord-errors.yml
+5
-0
spec/models/project_services/discord_service_spec.rb
spec/models/project_services/discord_service_spec.rb
+11
-0
No files found.
app/models/project_services/discord_service.rb
View file @
ddbc229d
...
...
@@ -59,6 +59,9 @@ class DiscordService < ChatNotificationService
embed
.
description
=
(
message
.
pretext
+
"
\n
"
+
Array
.
wrap
(
message
.
attachments
).
join
(
"
\n
"
)).
gsub
(
ATTACHMENT_REGEX
,
"
\\
k<entry> -
\\
k<name>
\n
"
)
end
end
rescue
RestClient
::
Exception
=>
error
log_error
(
error
.
message
)
false
end
def
custom_data
(
data
)
...
...
changelogs/unreleased/321659-handle-discord-errors.yml
0 → 100644
View file @
ddbc229d
---
title
:
Handle RestClient errors in Discord integration
merge_request
:
56112
author
:
type
:
fixed
spec/models/project_services/discord_service_spec.rb
View file @
ddbc229d
...
...
@@ -67,5 +67,16 @@ RSpec.describe DiscordService do
expect
{
subject
.
execute
(
sample_data
)
}.
to
raise_error
(
ArgumentError
,
/is blocked/
)
end
end
context
'when the Discord request fails'
do
before
do
WebMock
.
stub_request
(
:post
,
webhook_url
).
to_return
(
status:
400
)
end
it
'logs an error and returns false'
do
expect
(
subject
).
to
receive
(
:log_error
).
with
(
'400 Bad Request'
)
expect
(
subject
.
execute
(
sample_data
)).
to
be
(
false
)
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