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
0a283367
Commit
0a283367
authored
Aug 13, 2020
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate alert rules at model level
parent
d7239da8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
1 deletion
+3
-1
app/models/prometheus_alert.rb
app/models/prometheus_alert.rb
+1
-1
spec/models/prometheus_alert_spec.rb
spec/models/prometheus_alert_spec.rb
+2
-0
No files found.
app/models/prometheus_alert.rb
View file @
0a283367
...
...
@@ -22,7 +22,7 @@ class PrometheusAlert < ApplicationRecord
after_save
:clear_prometheus_adapter_cache!
after_destroy
:clear_prometheus_adapter_cache!
validates
:environment
,
:project
,
:prometheus_metric
,
presence:
true
validates
:environment
,
:project
,
:prometheus_metric
,
:threshold
,
:operator
,
presence:
true
validates
:runbook_url
,
length:
{
maximum:
255
},
allow_blank:
true
,
addressable_url:
{
enforce_sanitization:
true
,
ascii_only:
true
}
validate
:require_valid_environment_project!
...
...
spec/models/prometheus_alert_spec.rb
View file @
0a283367
...
...
@@ -50,6 +50,8 @@ RSpec.describe PrometheusAlert do
it
{
is_expected
.
to
validate_presence_of
(
:environment
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:prometheus_metric
)
}
it
{
is_expected
.
to
validate_presence_of
(
:operator
)
}
it
{
is_expected
.
to
validate_presence_of
(
:threshold
)
}
context
'when environment and metric belongs same project'
do
it
{
is_expected
.
to
be_valid
}
...
...
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