Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1498a9cb
Commit
1498a9cb
authored
Apr 11, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check `has_parent?` for determining validation type
parent
f7511caa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
app/models/namespace.rb
app/models/namespace.rb
+4
-0
app/validators/namespace_validator.rb
app/validators/namespace_validator.rb
+3
-3
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+1
-0
No files found.
app/models/namespace.rb
View file @
1498a9cb
...
@@ -220,6 +220,10 @@ class Namespace < ActiveRecord::Base
...
@@ -220,6 +220,10 @@ class Namespace < ActiveRecord::Base
Project
.
inside_path
(
full_path
)
Project
.
inside_path
(
full_path
)
end
end
def
has_parent?
parent
.
present?
end
private
private
def
repository_storage_paths
def
repository_storage_paths
...
...
app/validators/namespace_validator.rb
View file @
1498a9cb
...
@@ -74,7 +74,7 @@ class NamespaceValidator < ActiveModel::EachValidator
...
@@ -74,7 +74,7 @@ class NamespaceValidator < ActiveModel::EachValidator
preview blob blame raw files create_dir find_file
preview blob blame raw files create_dir find_file
artifacts graphs refs badges objects folders 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
)
def
self
.
valid_full_path?
(
full_path
)
path_segments
=
full_path
.
split
(
'/'
)
path_segments
=
full_path
.
split
(
'/'
)
...
@@ -120,8 +120,8 @@ class NamespaceValidator < ActiveModel::EachValidator
...
@@ -120,8 +120,8 @@ class NamespaceValidator < ActiveModel::EachValidator
def
validation_type
(
record
)
def
validation_type
(
record
)
case
record
case
record
when
Group
when
Namespace
record
.
parent_id
?
:wildcard
:
:top_level
record
.
has_parent?
?
:wildcard
:
:top_level
when
Project
when
Project
:wildcard
:wildcard
else
else
...
...
spec/models/namespace_spec.rb
View file @
1498a9cb
...
@@ -47,6 +47,7 @@ describe Namespace, models: true do
...
@@ -47,6 +47,7 @@ describe Namespace, models: true do
describe
"Respond to"
do
describe
"Respond to"
do
it
{
is_expected
.
to
respond_to
(
:human_name
)
}
it
{
is_expected
.
to
respond_to
(
:human_name
)
}
it
{
is_expected
.
to
respond_to
(
:to_param
)
}
it
{
is_expected
.
to
respond_to
(
:to_param
)
}
it
{
is_expected
.
to
respond_to
(
:has_parent?
)
}
end
end
describe
'#to_param'
do
describe
'#to_param'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment