Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-11-03 21:48:15 +0300
committerDouwe Maan <douwe@selenight.nl>2017-11-06 16:46:53 +0300
commita10925e1c37e7dab19de346c553311adfaccb86c (patch)
treeee211cc4bc6a830284a23583cd3d06e529793b10 /spec/validators/namespace_path_validator_spec.rb
parent97b80fefeb5da20798423b62b63fa9faa08ac118 (diff)
Reallow project paths ending in periods
Diffstat (limited to 'spec/validators/namespace_path_validator_spec.rb')
-rw-r--r--spec/validators/namespace_path_validator_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/validators/namespace_path_validator_spec.rb b/spec/validators/namespace_path_validator_spec.rb
new file mode 100644
index 00000000000..61e2845f35f
--- /dev/null
+++ b/spec/validators/namespace_path_validator_spec.rb
@@ -0,0 +1,38 @@
+require 'spec_helper'
+
+describe NamespacePathValidator do
+ let(:validator) { described_class.new(attributes: [:path]) }
+
+ describe '.valid_path?' do
+ it 'handles invalid utf8' do
+ expect(described_class.valid_path?("a\0weird\255path")).to be_falsey
+ end
+ end
+
+ describe '#validates_each' do
+ it 'adds a message when the path is not in the correct format' do
+ group = build(:group)
+
+ validator.validate_each(group, :path, "Path with spaces, and comma's!")
+
+ expect(group.errors[:path]).to include(Gitlab::PathRegex.namespace_format_message)
+ end
+
+ it 'adds a message when the path is reserved when creating' do
+ group = build(:group, path: 'help')
+
+ validator.validate_each(group, :path, 'help')
+
+ expect(group.errors[:path]).to include('help is a reserved name')
+ end
+
+ it 'adds a message when the path is reserved when updating' do
+ group = create(:group)
+ group.path = 'help'
+
+ validator.validate_each(group, :path, 'help')
+
+ expect(group.errors[:path]).to include('help is a reserved name')
+ end
+ end
+end