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
bc6e7e2c
Commit
bc6e7e2c
authored
Apr 20, 2020
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address invalid embed_json values
parent
68d82ed0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
app/services/metrics/dashboard/transient_embed_service.rb
app/services/metrics/dashboard/transient_embed_service.rb
+6
-0
spec/services/metrics/dashboard/transient_embed_service_spec.rb
...ervices/metrics/dashboard/transient_embed_service_spec.rb
+6
-0
No files found.
app/services/metrics/dashboard/transient_embed_service.rb
View file @
bc6e7e2c
...
...
@@ -24,6 +24,8 @@ module Metrics
override
:get_raw_dashboard
def
get_raw_dashboard
JSON
.
parse
(
params
[
:embed_json
])
rescue
JSON
::
ParserError
=>
e
invalid_embed_json!
(
e
.
message
)
end
override
:sequence
...
...
@@ -35,6 +37,10 @@ module Metrics
def
identifiers
Digest
::
SHA256
.
hexdigest
(
params
[
:embed_json
])
end
def
invalid_embed_json!
(
message
)
raise
DashboardProcessingError
.
new
(
"Parsing error for param :embed_json.
#{
message
}
"
)
end
end
end
end
spec/services/metrics/dashboard/transient_embed_service_spec.rb
View file @
bc6e7e2c
...
...
@@ -67,6 +67,12 @@ describe Metrics::Dashboard::TransientEmbedService, :use_clean_rails_memory_stor
expect
(
get_type_for_embed
(
alt_embed
)).
to
eq
(
'area-chart'
)
end
context
'when embed_json cannot be parsed as json'
do
let
(
:embed_json
)
{
''
}
it_behaves_like
'misconfigured dashboard service response'
,
:unprocessable_entity
end
private
def
get_embed_json
(
type
=
'line-graph'
)
...
...
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