Commit 6b0b2adc authored by allison.browne's avatar allison.browne

Code review feedback

Use predicate method and boolean rather than string
parent b2e86043
...@@ -363,7 +363,7 @@ module ProjectsHelper ...@@ -363,7 +363,7 @@ module ProjectsHelper
end end
def grafana_integration_enabled def grafana_integration_enabled
@project.grafana_integration&.enabled @project.grafana_integration&.enabled?
end end
private private
......
...@@ -17,8 +17,8 @@ class GrafanaIntegration < ApplicationRecord ...@@ -17,8 +17,8 @@ class GrafanaIntegration < ApplicationRecord
validates :enabled, inclusion: { in: [true, false] } validates :enabled, inclusion: { in: [true, false] }
def client def client
if enabled? return unless enabled?
@client ||= ::Grafana::Client.new(api_url: grafana_url.chomp('/'), token: token)
end @client ||= ::Grafana::Client.new(api_url: grafana_url.chomp('/'), token: token)
end end
end end
--- ---
title: Add flag to enable and disable grafana integration title: Migrate enabled flag on grafana_integrations table
merge_request: 19234 merge_request: 19234
author: author:
type: changed type: changed
...@@ -5,6 +5,6 @@ FactoryBot.define do ...@@ -5,6 +5,6 @@ FactoryBot.define do
project project
grafana_url { 'https://grafana.example.com' } grafana_url { 'https://grafana.example.com' }
token { SecureRandom.hex(10) } token { SecureRandom.hex(10) }
enabled { 'true' } enabled { true }
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment