summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/project.rb2
-rw-r--r--app/validators/project_path_validator.rb27
-rw-r--r--lib/constraints/project_url_constrainer.rb2
3 files changed, 2 insertions, 29 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 205b080c353..0ed4b4fddd6 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -196,7 +196,7 @@ class Project < ActiveRecord::Base
message: Gitlab::Regex.project_name_regex_message }
validates :path,
presence: true,
- project_path: true,
+ namespace: true,
length: { maximum: 255 },
format: { with: Gitlab::Regex.project_path_regex,
message: Gitlab::Regex.project_path_regex_message },
diff --git a/app/validators/project_path_validator.rb b/app/validators/project_path_validator.rb
deleted file mode 100644
index d41bdaeab84..00000000000
--- a/app/validators/project_path_validator.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# ProjectPathValidator
-#
-# Custom validator for GitLab project path values.
-#
-# Values are checked for formatting and exclusion from a list of reserved path
-# names.
-#
-# This is basically the same as the `NamespaceValidator` but it skips the validation
-# of the format with `Gitlab::Regex.namespace_regex`. The format of projects
-# is validated in the class itself.
-class ProjectPathValidator < NamespaceValidator
- def self.valid?(value)
- !reserved?(value)
- end
-
- def self.reserved?(value, type: :wildcard)
- super(value, type: :wildcard)
- end
-
- delegate :reserved?, to: :class
-
- def validate_each(record, attribute, value)
- if reserved?(value)
- record.errors.add(attribute, "#{value} is a reserved name")
- end
- end
-end
diff --git a/lib/constraints/project_url_constrainer.rb b/lib/constraints/project_url_constrainer.rb
index a10b4657d7d..f83fa1618a5 100644
--- a/lib/constraints/project_url_constrainer.rb
+++ b/lib/constraints/project_url_constrainer.rb
@@ -4,7 +4,7 @@ class ProjectUrlConstrainer
project_path = request.params[:project_id] || request.params[:id]
full_path = namespace_path + '/' + project_path
- unless ProjectPathValidator.valid?(project_path)
+ unless NamespaceValidator.valid_full_path?(full_path)
return false
end