summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-12-07 16:29:39 -0500
committerRobert Speicher <rspeicher@gmail.com>2015-12-07 16:57:26 -0500
commit2379c8beeac600c3352e33fda0c2b4f4f39c8b84 (patch)
tree52af8dd15a44bc8aeb508682fb26d8d28f7909bc
parent175f482c3cd584ba73c66e65aa180c1107e72913 (diff)
downloadgitlab-ce-rs-validators.tar.gz
Inline Gitlab::Blacklist in NamespaceValidatorrs-validators
-rw-r--r--app/validators/namespace_validator.rb36
-rw-r--r--lib/gitlab/blacklist.rb34
2 files changed, 32 insertions, 38 deletions
diff --git a/app/validators/namespace_validator.rb b/app/validators/namespace_validator.rb
index 4ab1706abda..10e35ce665a 100644
--- a/app/validators/namespace_validator.rb
+++ b/app/validators/namespace_validator.rb
@@ -2,21 +2,49 @@
#
# Custom validator for GitLab namespace values.
#
-# Values are checked for formatting and exclusion from `Gitlab::Blacklist.path`.
+# Values are checked for formatting and exclusion from a list of reserved path
+# names.
class NamespaceValidator < ActiveModel::EachValidator
+ RESERVED = %w(
+ admin
+ all
+ assets
+ ci
+ dashboard
+ files
+ groups
+ help
+ hooks
+ issues
+ merge_requests
+ notes
+ profile
+ projects
+ public
+ repository
+ s
+ search
+ services
+ snippets
+ teams
+ u
+ unsubscribes
+ users
+ ).freeze
+
def validate_each(record, attribute, value)
unless value =~ Gitlab::Regex.namespace_regex
record.errors.add(attribute, Gitlab::Regex.namespace_regex_message)
end
- if blacklisted?(value)
+ if reserved?(value)
record.errors.add(attribute, "#{value} is a reserved name")
end
end
private
- def blacklisted?(value)
- Gitlab::Blacklist.path.include?(value)
+ def reserved?(value)
+ RESERVED.include?(value)
end
end
diff --git a/lib/gitlab/blacklist.rb b/lib/gitlab/blacklist.rb
deleted file mode 100644
index 43145e0ee1b..00000000000
--- a/lib/gitlab/blacklist.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module Gitlab
- module Blacklist
- extend self
-
- def path
- %w(
- admin
- dashboard
- files
- groups
- help
- profile
- projects
- search
- public
- assets
- u
- s
- teams
- merge_requests
- issues
- users
- snippets
- services
- repository
- hooks
- notes
- unsubscribes
- all
- ci
- )
- end
- end
-end