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
5646f3f5
Commit
5646f3f5
authored
Sep 04, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve model validation
parent
e6d2465d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
11 deletions
+2
-11
app/models/prometheus_metric.rb
app/models/prometheus_metric.rb
+2
-11
No files found.
app/models/prometheus_metric.rb
View file @
5646f3f5
...
...
@@ -23,7 +23,8 @@ class PrometheusMetric < ActiveRecord::Base
validates
:y_label
,
presence:
true
validates
:unit
,
presence:
true
validate
:require_project
validates
:project
,
presence:
true
,
unless: :common?
validates
:project
,
absence:
true
,
if: :common?
scope
:common
,
->
{
where
(
common:
true
)
}
...
...
@@ -85,14 +86,4 @@ class PrometheusMetric < ActiveRecord::Base
}
end
end
private
def
require_project
if
project
errors
.
add
(
:project
,
"cannot be set if this is common metric"
)
if
common?
else
errors
.
add
(
:project
,
"has to be set when this is project-specific metric"
)
unless
common?
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