Commit c0116926 authored by Douwe Maan's avatar Douwe Maan

Rename namespace_regex to namespace_path_regex.

parent 164a29df
......@@ -33,8 +33,8 @@ class Namespace < ActiveRecord::Base
presence: true,
length: { within: 1..255 },
exclusion: { in: Gitlab::Blacklist.path },
format: { with: Gitlab::Regex.namespace_regex,
message: Gitlab::Regex.namespace_regex_message }
format: { with: Gitlab::Regex.namespace_path_regex,
message: Gitlab::Regex.namespace_path_regex_message }
delegate :name, to: :owner, allow_nil: true, prefix: true
......
......@@ -131,8 +131,8 @@ class User < ActiveRecord::Base
presence: true,
uniqueness: { case_sensitive: false },
exclusion: { in: Gitlab::Blacklist.path },
format: { with: Gitlab::Regex.namespace_regex,
message: Gitlab::Regex.namespace_regex_message }
format: { with: Gitlab::Regex.namespace_path_regex,
message: Gitlab::Regex.namespace_path_regex_message }
validates :notification_level, inclusion: { in: Notification.notification_levels }, presence: true
validate :namespace_uniq, if: ->(user) { user.username_changed? }
......
......@@ -3,7 +3,7 @@ module Gitlab
# Common methods for ReferenceFilters that support an optional cross-project
# reference.
module CrossProjectReference
NAMING_PATTERN = Gitlab::Regex::NAMESPACE_REGEX_STR
NAMING_PATTERN = Gitlab::Regex::NAMESPACE_PATH_REGEX_STR
PROJECT_PATTERN = "(?<project>#{NAMING_PATTERN}/#{NAMING_PATTERN})"
# Given a cross-project reference string, get the Project record
......
......@@ -22,7 +22,7 @@ module Gitlab
end
# Pattern used to extract `@user` user references from text
USER_PATTERN = /@(?<user>#{Gitlab::Regex::NAMESPACE_REGEX_STR})/
USER_PATTERN = /@(?<user>#{Gitlab::Regex::NAMESPACE_PATH_REGEX_STR})/
def call
replace_text_nodes_matching(USER_PATTERN) do |content|
......
......@@ -85,7 +85,7 @@ module Gitlab
private
NAME_STR = Gitlab::Regex::NAMESPACE_REGEX_STR
NAME_STR = Gitlab::Regex::NAMESPACE_PATH_REGEX_STR
PROJ_STR = "(?<project>#{NAME_STR}/#{NAME_STR})"
REFERENCE_PATTERN = %r{
......
......@@ -2,13 +2,13 @@ module Gitlab
module Regex
extend self
NAMESPACE_REGEX_STR = '(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])'.freeze
NAMESPACE_PATH_REGEX_STR = '(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])'.freeze
def namespace_regex
@namespace_regex ||= /\A#{NAMESPACE_REGEX_STR}\z/.freeze
def namespace_path_regex
@namespace_path_regex ||= /\A#{NAMESPACE_PATH_REGEX_STR}\z/.freeze
end
def namespace_regex_message
def namespace_path_regex_message
"can contain only letters, digits, '_', '-' and '.'. " \
"Cannot start with '-' or end in '.'." \
end
......
......@@ -145,7 +145,7 @@ describe API::API, api: true do
expect(json_response['message']['projects_limit']).
to eq(['must be greater than or equal to 0'])
expect(json_response['message']['username']).
to eq([Gitlab::Regex.send(:namespace_regex_message)])
to eq([Gitlab::Regex.send(:namespace_path_regex_message)])
end
it "shouldn't available for non admin users" do
......@@ -271,7 +271,7 @@ describe API::API, api: true do
expect(json_response['message']['projects_limit']).
to eq(['must be greater than or equal to 0'])
expect(json_response['message']['username']).
to eq([Gitlab::Regex.send(:namespace_regex_message)])
to eq([Gitlab::Regex.send(:namespace_path_regex_message)])
end
context "with existing user" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment