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
path: root/app
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-07-12 15:59:38 +0300
committerJan Provaznik <jprovaznik@gitlab.com>2019-07-12 15:59:38 +0300
commit907154957ef89c1f0df1de3c665418146cc93f98 (patch)
treea78292af3d7f93f943133c36b29647a7cdf04dcd /app
parentfd407d065861b092dfc4f53ef76ab44991998753 (diff)
parent82e6ed310b1bb5e7faf44742defaf65b74926195 (diff)
Merge branch 'bvl-rename-routes-after-user-rename' into 'master'
Set the name of a user-namespace to the user name See merge request gitlab-org/gitlab-ce!23272
Diffstat (limited to 'app')
-rw-r--r--app/models/namespace.rb3
-rw-r--r--app/models/user.rb5
-rw-r--r--app/validators/namespace_name_validator.rb12
3 files changed, 4 insertions, 16 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index af50293a179..1d95590bac9 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -41,8 +41,7 @@ class Namespace < ApplicationRecord
validates :owner, presence: true, unless: ->(n) { n.type == "Group" }
validates :name,
presence: true,
- length: { maximum: 255 },
- namespace_name: true
+ length: { maximum: 255 }
validates :description, length: { maximum: 255 }
validates :path,
diff --git a/app/models/user.rb b/app/models/user.rb
index 26be197209a..02637b70f03 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1117,9 +1117,10 @@ class User < ApplicationRecord
def ensure_namespace_correct
if namespace
- namespace.path = namespace.name = username if username_changed?
+ namespace.path = username if username_changed?
+ namespace.name = name if name_changed?
else
- build_namespace(path: username, name: username)
+ build_namespace(path: username, name: name)
end
end
diff --git a/app/validators/namespace_name_validator.rb b/app/validators/namespace_name_validator.rb
deleted file mode 100644
index fb1c241037c..00000000000
--- a/app/validators/namespace_name_validator.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-# NamespaceNameValidator
-#
-# Custom validator for GitLab namespace name strings.
-class NamespaceNameValidator < ActiveModel::EachValidator
- def validate_each(record, attribute, value)
- unless value =~ Gitlab::Regex.namespace_name_regex
- record.errors.add(attribute, Gitlab::Regex.namespace_name_regex_message)
- end
- end
-end