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
b2e86043
Commit
b2e86043
authored
Oct 30, 2019
by
allison.browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add enabled check within client method
parent
7cb54ab3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
app/models/grafana_integration.rb
app/models/grafana_integration.rb
+3
-1
spec/models/grafana_integration_spec.rb
spec/models/grafana_integration_spec.rb
+18
-0
No files found.
app/models/grafana_integration.rb
View file @
b2e86043
...
...
@@ -17,6 +17,8 @@ class GrafanaIntegration < ApplicationRecord
validates
:enabled
,
inclusion:
{
in:
[
true
,
false
]
}
def
client
@client
||=
::
Grafana
::
Client
.
new
(
api_url:
grafana_url
.
chomp
(
'/'
),
token:
token
)
if
enabled?
@client
||=
::
Grafana
::
Client
.
new
(
api_url:
grafana_url
.
chomp
(
'/'
),
token:
token
)
end
end
end
spec/models/grafana_integration_spec.rb
View file @
b2e86043
...
...
@@ -48,4 +48,22 @@ describe GrafanaIntegration do
).
for
(
:enabled
)
end
end
describe
'.client'
do
subject
(
:grafana_integration
)
{
create
(
:grafana_integration
)
}
context
'with grafana integration disabled'
do
it
'returns a grafana client'
do
expect
(
grafana_integration
.
client
).
to
be_an_instance_of
(
::
Grafana
::
Client
)
end
end
context
'with grafana integration enabled'
do
it
'returns nil'
do
grafana_integration
.
update
(
enabled:
false
)
expect
(
grafana_integration
.
client
).
to
be
(
nil
)
end
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