summaryrefslogtreecommitdiff
path: root/spec/models/project_tracing_setting_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-02 12:09:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-02 12:09:03 +0000
commit6092dcc437ef3e9300cc32cb7c6daea9448cba40 (patch)
tree7a93e011871915b658537ef4787b87633ada5178 /spec/models/project_tracing_setting_spec.rb
parent251d3d2b234a4b449edefec4ed8dcf9bc2f8be37 (diff)
downloadgitlab-ce-6092dcc437ef3e9300cc32cb7c6daea9448cba40.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/project_tracing_setting_spec.rb')
-rw-r--r--spec/models/project_tracing_setting_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/project_tracing_setting_spec.rb b/spec/models/project_tracing_setting_spec.rb
new file mode 100644
index 00000000000..a7e4e557b25
--- /dev/null
+++ b/spec/models/project_tracing_setting_spec.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe ProjectTracingSetting do
+ describe '#external_url' do
+ let_it_be(:project) { create(:project) }
+
+ let(:tracing_setting) { project.build_tracing_setting }
+
+ describe 'Validations' do
+ describe 'external_url' do
+ it 'accepts a valid url' do
+ tracing_setting.external_url = 'https://gitlab.com'
+
+ expect(tracing_setting).to be_valid
+ end
+
+ it 'fails with an invalid url' do
+ tracing_setting.external_url = 'gitlab.com'
+
+ expect(tracing_setting).to be_invalid
+ end
+
+ it 'fails with a blank string' do
+ tracing_setting.external_url = nil
+
+ expect(tracing_setting).to be_invalid
+ end
+
+ it 'sanitizes the url' do
+ tracing_setting.external_url = %{https://replaceme.com/'><script>alert(document.cookie)</script>}
+
+ expect(tracing_setting).to be_valid
+ expect(tracing_setting.external_url).to eq(%{https://replaceme.com/'&gt;})
+ end
+ end
+ end
+ end
+end