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
66d54e45
Commit
66d54e45
authored
Apr 07, 2020
by
Sean Arnold
Committed by
Rémy Coutable
Apr 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "PrometheusService validation bug prevents saving for non-manual configurations"
parent
827594ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
+15
-3
app/models/project_services/prometheus_service.rb
app/models/project_services/prometheus_service.rb
+3
-3
spec/models/project_services/prometheus_service_spec.rb
spec/models/project_services/prometheus_service_spec.rb
+12
-0
No files found.
app/models/project_services/prometheus_service.rb
View file @
66d54e45
...
...
@@ -13,9 +13,9 @@ class PrometheusService < MonitoringService
# to allow localhost URLs when the following conditions are true:
# 1. project is the self-monitoring project.
# 2. api_url is the internal Prometheus URL.
with_options
presence:
true
,
if: :manual_configuration?
do
validates
:api_url
,
public_url:
true
,
unless:
proc
{
|
object
|
object
.
allow_local_api_url?
}
validates
:api_url
,
url:
true
,
if:
proc
{
|
object
|
object
.
allow_local_api_url?
}
with_options
presence:
true
do
validates
:api_url
,
public_url:
true
,
if:
->
(
object
)
{
object
.
manual_configuration?
&&
!
object
.
allow_local_api_url?
}
validates
:api_url
,
url:
true
,
if:
->
(
object
)
{
object
.
manual_configuration?
&&
object
.
allow_local_api_url?
}
end
before_save
:synchronize_service_state
...
...
spec/models/project_services/prometheus_service_spec.rb
View file @
66d54e45
...
...
@@ -48,6 +48,18 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
it
'does not validate presence of api_url'
do
expect
(
service
).
not_to
validate_presence_of
(
:api_url
)
expect
(
service
.
valid?
).
to
eq
(
true
)
end
context
'local connections allowed'
do
before
do
stub_application_setting
(
allow_local_requests_from_web_hooks_and_services:
true
)
end
it
'does not validate presence of api_url'
do
expect
(
service
).
not_to
validate_presence_of
(
:api_url
)
expect
(
service
.
valid?
).
to
eq
(
true
)
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