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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
8926b37d
Commit
8926b37d
authored
Apr 25, 2019
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer safe_load and deep_symbolize_keys
parent
4a5c48c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
12 deletions
+11
-12
lib/gitlab/metrics/dashboard/processor.rb
lib/gitlab/metrics/dashboard/processor.rb
+6
-7
lib/gitlab/metrics/dashboard/service.rb
lib/gitlab/metrics/dashboard/service.rb
+2
-2
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+1
-1
spec/lib/gitlab/metrics/dashboard/service_spec.rb
spec/lib/gitlab/metrics/dashboard/service_spec.rb
+2
-2
No files found.
lib/gitlab/metrics/dashboard/processor.rb
View file @
8926b37d
...
@@ -21,13 +21,12 @@ module Gitlab
...
@@ -21,13 +21,12 @@ module Gitlab
# Returns a new dashboard hash with the results of
# Returns a new dashboard hash with the results of
# running transforms on the dashboard.
# running transforms on the dashboard.
def
process
(
dashboard
)
def
process
(
raw_dashboard
)
dashboard
=
dashboard
.
deep_symbolize_keys
raw_dashboard
.
deep_symbolize_keys
.
tap
do
|
dashboard
|
sequence
.
each
do
|
stage
|
stage_params
=
[
@project
,
@environment
]
stage
.
new
(
@project
,
@environment
).
transform!
(
dashboard
)
sequence
.
each
{
|
stage
|
stage
.
new
(
*
stage_params
).
transform!
(
dashboard
)
}
end
end
dashboard
end
end
private
private
...
...
lib/gitlab/metrics/dashboard/service.rb
View file @
8926b37d
...
@@ -23,7 +23,7 @@ module Gitlab
...
@@ -23,7 +23,7 @@ module Gitlab
# Returns the base metrics shipped with every GitLab service.
# Returns the base metrics shipped with every GitLab service.
def
system_dashboard
def
system_dashboard
YAML
.
load_file
(
SYSTEM_DASHBOARD_PATH
)
YAML
.
safe_load
(
File
.
read
(
SYSTEM_DASHBOARD_PATH
)
)
end
end
def
cache_key
def
cache_key
...
@@ -32,7 +32,7 @@ module Gitlab
...
@@ -32,7 +32,7 @@ module Gitlab
# Returns a new dashboard Hash, supplemented with DB info
# Returns a new dashboard Hash, supplemented with DB info
def
process_dashboard
(
dashboard
)
def
process_dashboard
(
dashboard
)
Processor
.
new
(
project
,
params
[
:environment
]).
process
(
dashboard
)
Gitlab
::
Metrics
::
Dashboard
::
Processor
.
new
(
project
,
params
[
:environment
]).
process
(
dashboard
)
end
end
end
end
end
end
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
8926b37d
...
@@ -485,7 +485,7 @@ describe Projects::EnvironmentsController do
...
@@ -485,7 +485,7 @@ describe Projects::EnvironmentsController do
context
'when the dashboard could not be provided'
do
context
'when the dashboard could not be provided'
do
before
do
before
do
allow
(
YAML
).
to
receive
(
:
load_file
).
and_return
({})
allow
(
YAML
).
to
receive
(
:
safe_load
).
and_return
({})
end
end
it
'returns an error response'
do
it
'returns an error response'
do
...
...
spec/lib/gitlab/metrics/dashboard/service_spec.rb
View file @
8926b37d
...
@@ -19,7 +19,7 @@ describe Gitlab::Metrics::Dashboard::Service, :use_clean_rails_memory_store_cach
...
@@ -19,7 +19,7 @@ describe Gitlab::Metrics::Dashboard::Service, :use_clean_rails_memory_store_cach
end
end
it
'caches the dashboard for subsequent calls'
do
it
'caches the dashboard for subsequent calls'
do
expect
(
YAML
).
to
receive
(
:
load_file
).
once
.
and_call_original
expect
(
YAML
).
to
receive
(
:
safe_load
).
once
.
and_call_original
described_class
.
new
(
project
,
environment
).
get_dashboard
described_class
.
new
(
project
,
environment
).
get_dashboard
described_class
.
new
(
project
,
environment
).
get_dashboard
described_class
.
new
(
project
,
environment
).
get_dashboard
...
@@ -27,7 +27,7 @@ describe Gitlab::Metrics::Dashboard::Service, :use_clean_rails_memory_store_cach
...
@@ -27,7 +27,7 @@ describe Gitlab::Metrics::Dashboard::Service, :use_clean_rails_memory_store_cach
context
'when the dashboard is configured incorrectly'
do
context
'when the dashboard is configured incorrectly'
do
before
do
before
do
allow
(
YAML
).
to
receive
(
:
load_file
).
and_return
({})
allow
(
YAML
).
to
receive
(
:
safe_load
).
and_return
({})
end
end
it
'returns an appropriate message and status code'
do
it
'returns an appropriate message and status code'
do
...
...
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