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
aa8067bd
Commit
aa8067bd
authored
Mar 31, 2020
by
Mikolaj Wawrzyniak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add .id method to PrometheusPanel class
parent
d6423b73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
app/models/performance_monitoring/prometheus_panel.rb
app/models/performance_monitoring/prometheus_panel.rb
+5
-1
ee/spec/models/performance_monitoring/prometheus_panel_spec.rb
...ec/models/performance_monitoring/prometheus_panel_spec.rb
+21
-0
No files found.
app/models/performance_monitoring/prometheus_panel.rb
View file @
aa8067bd
...
...
@@ -4,7 +4,7 @@ module PerformanceMonitoring
class
PrometheusPanel
include
ActiveModel
::
Model
attr_accessor
:type
,
:title
,
:y_label
,
:weight
,
:metrics
attr_accessor
:type
,
:title
,
:y_label
,
:weight
,
:metrics
,
:y_axis
validates
:title
,
presence:
true
validates
:metrics
,
presence:
true
...
...
@@ -20,5 +20,9 @@ module PerformanceMonitoring
panel
.
tap
(
&
:validate!
)
end
def
id
(
group_title
)
Digest
::
SHA2
.
hexdigest
([
group_title
,
type
,
title
].
join
)
end
end
end
ee/spec/models/performance_monitoring/prometheus_panel_spec.rb
View file @
aa8067bd
...
...
@@ -18,6 +18,16 @@ describe PerformanceMonitoring::PrometheusPanel do
}
end
describe
'#new'
do
it
'accepts old schema format'
do
expect
{
described_class
.
new
(
json_content
)
}.
not_to
raise_error
end
it
'accepts new schema format'
do
expect
{
described_class
.
new
(
json_content
.
merge
(
"y_axis"
=>
{
"precision"
=>
0
}))
}.
not_to
raise_error
end
end
describe
'.from_json'
do
subject
{
described_class
.
from_json
(
json_content
)
}
...
...
@@ -52,4 +62,15 @@ describe PerformanceMonitoring::PrometheusPanel do
end
end
end
describe
'.id'
do
it
'returns hexdigest of group_title, type and title as the panel id'
do
group_title
=
'Business Group'
panel_type
=
'area-chart'
panel_title
=
'New feature requests made'
expect
(
Digest
::
SHA2
).
to
receive
(
:hexdigest
).
with
(
"
#{
group_title
}#{
panel_type
}#{
panel_title
}
"
).
and_return
(
'hexdigest'
)
expect
(
described_class
.
new
(
title:
panel_title
,
type:
panel_type
).
id
(
group_title
)).
to
eql
'hexdigest'
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