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:
-rw-r--r--app/models/namespace.rb4
-rw-r--r--app/validators/namespace_validator.rb6
-rw-r--r--spec/models/namespace_spec.rb1
3 files changed, 8 insertions, 3 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 9bfa731785f..1570470d63f 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -220,6 +220,10 @@ class Namespace < ActiveRecord::Base
Project.inside_path(full_path)
end
+ def has_parent?
+ parent.present?
+ end
+
private
def repository_storage_paths
diff --git a/app/validators/namespace_validator.rb b/app/validators/namespace_validator.rb
index 8a0e18612ec..ed71d5ad5b5 100644
--- a/app/validators/namespace_validator.rb
+++ b/app/validators/namespace_validator.rb
@@ -74,7 +74,7 @@ class NamespaceValidator < ActiveModel::EachValidator
preview blob blame raw files create_dir find_file
artifacts graphs refs badges objects folders file])
- STRICT_RESERVED = (TOP_LEVEL_ROUTES | WILDCARD_ROUTES)
+ STRICT_RESERVED = (TOP_LEVEL_ROUTES | WILDCARD_ROUTES).freeze
def self.valid_full_path?(full_path)
path_segments = full_path.split('/')
@@ -120,8 +120,8 @@ class NamespaceValidator < ActiveModel::EachValidator
def validation_type(record)
case record
- when Group
- record.parent_id ? :wildcard : :top_level
+ when Namespace
+ record.has_parent? ? :wildcard : :top_level
when Project
:wildcard
else
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index e406d0a16bd..6775fd2f1b8 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -47,6 +47,7 @@ describe Namespace, models: true do
describe "Respond to" do
it { is_expected.to respond_to(:human_name) }
it { is_expected.to respond_to(:to_param) }
+ it { is_expected.to respond_to(:has_parent?) }
end
describe '#to_param' do