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
b303932a
Commit
b303932a
authored
Jun 21, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bvl-validate-path-update' into 'master'
Rebuild the dynamic path before validating it Closes #33746 See merge request !12213
parents
b5c3ad75
79393a35
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
9 deletions
+18
-9
routable.rb
app/models/concerns/routable.rb
+8
-8
dynamic_path_validator.rb
app/validators/dynamic_path_validator.rb
+1
-1
dynamic_path_validator_spec.rb
spec/validators/dynamic_path_validator_spec.rb
+9
-0
No files found.
app/models/concerns/routable.rb
View file @
b303932a
...
...
@@ -107,6 +107,14 @@ module Routable
RequestStore
[
key
]
||=
uncached_full_path
end
def
build_full_path
if
parent
&&
path
parent
.
full_path
+
'/'
+
path
else
path
end
end
private
def
uncached_full_path
...
...
@@ -135,14 +143,6 @@ module Routable
end
end
def
build_full_path
if
parent
&&
path
parent
.
full_path
+
'/'
+
path
else
path
end
end
def
update_route
prepare_route
route
.
save
...
...
app/validators/dynamic_path_validator.rb
View file @
b303932a
...
...
@@ -26,7 +26,7 @@ class DynamicPathValidator < ActiveModel::EachValidator
end
def
path_valid_for_record?
(
record
,
value
)
full_path
=
record
.
respond_to?
(
:
full_path
)
?
record
.
full_path
:
value
full_path
=
record
.
respond_to?
(
:
build_full_path
)
?
record
.
build_
full_path
:
value
return
true
unless
full_path
...
...
spec/validators/dynamic_path_validator_spec.rb
View file @
b303932a
...
...
@@ -84,5 +84,14 @@ describe DynamicPathValidator do
expect
(
group
.
errors
[
:path
]).
to
include
(
'users is a reserved name'
)
end
it
'updating to an invalid path is not allowed'
do
project
=
create
(
:empty_project
)
project
.
path
=
'update'
validator
.
validate_each
(
project
,
:path
,
'update'
)
expect
(
project
.
errors
[
:path
]).
to
include
(
'update is a reserved name'
)
end
end
end
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