summaryrefslogtreecommitdiff
path: root/spec/validators
diff options
context:
space:
mode:
authorRoger Rüttimann <roger.ruettimann@gmail.com>2018-08-30 12:53:06 +0000
committerPhil Hughes <me@iamphill.com>2018-08-30 12:53:06 +0000
commit93b9bfd93a841b7f86e6aeab3f9c5e9ede3a4503 (patch)
tree8bfec898a33d9b0b1693e73ce27a61db54881a66 /spec/validators
parent3113fb848001fdea3a039295002d7752b0feebbb (diff)
downloadgitlab-ce-93b9bfd93a841b7f86e6aeab3f9c5e9ede3a4503.tar.gz
Allow whitelisting for "external collaborator by default" setting
Diffstat (limited to 'spec/validators')
-rw-r--r--spec/validators/js_regex_validator_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/validators/js_regex_validator_spec.rb b/spec/validators/js_regex_validator_spec.rb
new file mode 100644
index 00000000000..aeb55cdc0e5
--- /dev/null
+++ b/spec/validators/js_regex_validator_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe JsRegexValidator do
+ describe '#validates_each' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:validator) { described_class.new(attributes: [:user_default_internal_regex]) }
+ let(:application_setting) { build(:application_setting, user_default_external: true) }
+
+ where(:user_default_internal_regex, :result) do
+ nil | []
+ '' | []
+ '(?#comment)' | ['Regex Pattern (?#comment) can not be expressed in Javascript']
+ '(?(a)b|c)' | ['invalid conditional pattern: /(?(a)b|c)/i']
+ '[a-z&&[^uo]]' | ["Dropped unsupported set intersection '[a-z&&[^uo]]' at index 0",
+ "Dropped unsupported nested negative set data '[^uo]' at index 6"]
+ end
+
+ with_them do
+ it 'generates correct errors' do
+ validator.validate_each(application_setting, :user_default_internal_regex, user_default_internal_regex)
+
+ expect(application_setting.errors[:user_default_internal_regex]).to eq result
+ end
+ end
+ end
+end