summaryrefslogtreecommitdiff
path: root/spec/models/grafana_integration_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-03 21:07:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-03 21:07:29 +0000
commit1da3754b25657f49afdcb0b942506d365b1ee89d (patch)
tree9f4bfa94fdd1762ef99e6a61bf180ac8cd7b5616 /spec/models/grafana_integration_spec.rb
parent25521def84a6987fe9d4265b560e930bfb32c195 (diff)
downloadgitlab-ce-1da3754b25657f49afdcb0b942506d365b1ee89d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/grafana_integration_spec.rb')
-rw-r--r--spec/models/grafana_integration_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/grafana_integration_spec.rb b/spec/models/grafana_integration_spec.rb
new file mode 100644
index 00000000000..f8973097a40
--- /dev/null
+++ b/spec/models/grafana_integration_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe GrafanaIntegration do
+ describe 'associations' do
+ it { is_expected.to belong_to(:project) }
+ end
+
+ describe 'validations' do
+ it { is_expected.to validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:token) }
+
+ it 'disallows invalid urls for grafana_url' do
+ unsafe_url = %{https://replaceme.com/'><script>alert(document.cookie)</script>}
+ non_ascii_url = 'http://gitlab.com/api/0/projects/project1/something€'
+ blank_url = ''
+ excessively_long_url = 'https://grafan' + 'a' * 1024 + '.com'
+
+ is_expected.not_to allow_values(
+ unsafe_url,
+ non_ascii_url,
+ blank_url,
+ excessively_long_url
+ ).for(:grafana_url)
+ end
+
+ it 'allows valid urls for grafana_url' do
+ external_url = 'http://grafana.com/'
+ internal_url = 'http://192.168.1.1'
+
+ is_expected.to allow_value(
+ external_url,
+ internal_url
+ ).for(:grafana_url)
+ end
+ end
+end