BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
bccf8d86
Commit
bccf8d86
authored
Apr 12, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `NamespaceValidator` to `DynamicPathValidator`
This reflects better that it validates paths instead of a namespace model
parent
3143a5d2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
13 additions
and
10 deletions
+13
-10
namespace.rb
app/models/namespace.rb
+1
-1
project.rb
app/models/project.rb
+1
-1
user.rb
app/models/user.rb
+1
-1
dynamic_path_validator.rb
app/validators/dynamic_path_validator.rb
+6
-3
group_url_constrainer.rb
lib/constraints/group_url_constrainer.rb
+1
-1
project_url_constrainer.rb
lib/constraints/project_url_constrainer.rb
+1
-1
router.rb
lib/gitlab/etag_caching/router.rb
+1
-1
dynamic_path_validator_spec.rb
spec/validators/dynamic_path_validator_spec.rb
+1
-1
No files found.
app/models/namespace.rb
View file @
bccf8d86
...
...
@@ -33,7 +33,7 @@ class Namespace < ActiveRecord::Base
validates
:path
,
presence:
true
,
length:
{
maximum:
255
},
namespace
:
true
dynamic_path
:
true
validate
:nesting_level_allowed
...
...
app/models/project.rb
View file @
bccf8d86
...
...
@@ -196,7 +196,7 @@ class Project < ActiveRecord::Base
message:
Gitlab
::
Regex
.
project_name_regex_message
}
validates
:path
,
presence:
true
,
namespace
:
true
,
dynamic_path
:
true
,
length:
{
maximum:
255
},
format:
{
with:
Gitlab
::
Regex
.
project_path_regex
,
message:
Gitlab
::
Regex
.
project_path_regex_message
},
...
...
app/models/user.rb
View file @
bccf8d86
...
...
@@ -118,7 +118,7 @@ class User < ActiveRecord::Base
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
,
less_than_or_equal_to:
Gitlab
::
Database
::
MAX_INT_VALUE
}
validates
:username
,
namespace
:
true
,
dynamic_path
:
true
,
presence:
true
,
uniqueness:
{
case_sensitive:
false
}
...
...
app/validators/
namespace
_validator.rb
→
app/validators/
dynamic_path
_validator.rb
View file @
bccf8d86
#
Namespace
Validator
#
DynamicPath
Validator
#
# Custom validator for GitLab namespace values.
# Custom validator for GitLab path values.
# These paths are assigned to `Namespace` (& `Group` as a subclass) & `Project`
#
# Values are checked for formatting and exclusion from a list of reserved path
# names.
class
Namespace
Validator
<
ActiveModel
::
EachValidator
class
DynamicPath
Validator
<
ActiveModel
::
EachValidator
# All routes that appear on the top level must be listed here.
# This will make sure that groups cannot be created with these names
# as these routes would be masked by the paths already in place.
...
...
@@ -124,6 +125,8 @@ class NamespaceValidator < ActiveModel::EachValidator
record
.
has_parent?
?
:
wildcard
:
:top_level
when
Project
:wildcard
when
User
:top_level
else
:strict
end
...
...
lib/constraints/group_url_constrainer.rb
View file @
bccf8d86
...
...
@@ -2,7 +2,7 @@ class GroupUrlConstrainer
def
matches?
(
request
)
id
=
request
.
params
[
:id
]
return
false
unless
Namespace
Validator
.
valid_full_path?
(
id
)
return
false
unless
DynamicPath
Validator
.
valid_full_path?
(
id
)
Group
.
find_by_full_path
(
id
).
present?
end
...
...
lib/constraints/project_url_constrainer.rb
View file @
bccf8d86
...
...
@@ -4,7 +4,7 @@ class ProjectUrlConstrainer
project_path
=
request
.
params
[
:project_id
]
||
request
.
params
[
:id
]
full_path
=
namespace_path
+
'/'
+
project_path
unless
Namespace
Validator
.
valid_full_path?
(
full_path
)
unless
DynamicPath
Validator
.
valid_full_path?
(
full_path
)
return
false
end
...
...
lib/gitlab/etag_caching/router.rb
View file @
bccf8d86
...
...
@@ -10,7 +10,7 @@ module Gitlab
# - Ending in `issues/id`/rendered_title` for the `issue_title` route
USED_IN_ROUTES
=
%w[noteable issue notes issues renderred_title
commit pipelines merge_requests new]
.
freeze
RESERVED_WORDS
=
Namespace
Validator
::
WILDCARD_ROUTES
-
USED_IN_ROUTES
RESERVED_WORDS
=
DynamicPath
Validator
::
WILDCARD_ROUTES
-
USED_IN_ROUTES
RESERVED_WORDS_REGEX
=
Regexp
.
union
(
*
RESERVED_WORDS
)
ROUTES
=
[
Gitlab
::
EtagCaching
::
Router
::
Route
.
new
(
...
...
spec/validators/
namespace
_validator_spec.rb
→
spec/validators/
dynamic_path
_validator_spec.rb
View file @
bccf8d86
require
'spec_helper'
describe
Namespace
Validator
do
describe
DynamicPath
Validator
do
let
(
:validator
)
{
described_class
.
new
(
attributes:
[
:path
])
}
# Pass in a full path to remove the format segment:
...
...
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