summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2018-02-07 01:53:18 +0100
committerPawel Chojnacki <pawel@chojnacki.ws>2018-02-07 01:54:09 +0100
commit8cb105cf5fe0418c34cf4448304062edffe309dc (patch)
tree10e88fd26f6738ae4b03dfc733893bb1f4f965f2
parent277f7fef2c7369dc9fc8f54f9ad35a2d3086ee2b (diff)
downloadgitlab-ce-8cb105cf5fe0418c34cf4448304062edffe309dc.tar.gz
Fix order of checks in editable? method.
+ address small nitpicks
-rw-r--r--app/models/project_services/prometheus_service.rb7
-rw-r--r--spec/factories/projects.rb2
-rw-r--r--spec/factories/services.rb4
3 files changed, 7 insertions, 6 deletions
diff --git a/app/models/project_services/prometheus_service.rb b/app/models/project_services/prometheus_service.rb
index e07340d572d..1bb576ff971 100644
--- a/app/models/project_services/prometheus_service.rb
+++ b/app/models/project_services/prometheus_service.rb
@@ -28,7 +28,7 @@ class PrometheusService < MonitoringService
end
def editable?
- !prometheus_installed? || manual_configuration?
+ manual_configuration? || !prometheus_installed?
end
def title
@@ -126,7 +126,8 @@ class PrometheusService < MonitoringService
end
def prometheus_installed?
- return false if template? || !project
+ return false if template?
+ return false unless project
project.clusters.enabled.any? { |cluster| cluster.application_prometheus&.installed? }
end
@@ -157,7 +158,7 @@ class PrometheusService < MonitoringService
end
def synchronize_service_state!
- self.active = prometheus_installed? || self.manual_configuration?
+ self.active = prometheus_installed? || manual_configuration?
true
end
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index 9eef923c30d..f92b307fee4 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -249,7 +249,7 @@ FactoryBot.define do
project.create_prometheus_service(
active: true,
properties: {
- api_url: 'https://prometheus.example.com',
+ api_url: 'https://prometheus.example.com/',
manual_configuration: true
}
)
diff --git a/spec/factories/services.rb b/spec/factories/services.rb
index faedcc38c8d..0d4fd49bf3a 100644
--- a/spec/factories/services.rb
+++ b/spec/factories/services.rb
@@ -30,8 +30,8 @@ FactoryBot.define do
project
active true
properties({
- manual_configuration: true,
- api_url: 'https://prometheus.example.com/'
+ api_url: 'https://prometheus.example.com/',
+ manual_configuration: true
})
end