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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
414c4e3f
Commit
414c4e3f
authored
Oct 26, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper methods to redirect legacy paths
parent
3a8cf276
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
changelogs/unreleased/bvl-free-paths.yml
changelogs/unreleased/bvl-free-paths.yml
+5
-0
lib/gitlab/routing.rb
lib/gitlab/routing.rb
+9
-0
spec/support/legacy_path_redirect_shared_examples.rb
spec/support/legacy_path_redirect_shared_examples.rb
+13
-0
No files found.
changelogs/unreleased/bvl-free-paths.yml
0 → 100644
View file @
414c4e3f
---
title
:
Free up some reserved group names
merge_request
:
15052
author
:
type
:
other
lib/gitlab/routing.rb
View file @
414c4e3f
...
...
@@ -40,5 +40,14 @@ module Gitlab
def
self
.
url_helpers
@url_helpers
||=
Gitlab
::
Application
.
routes
.
url_helpers
end
def
self
.
redirect_legacy_paths
(
router
,
*
paths
)
paths
.
each
do
|
path
|
router
.
match
"/
#{
path
}
(/*rest)"
,
via:
[
:get
,
:post
,
:patch
,
:delete
],
to:
router
.
redirect
{
|
_params
,
request
|
request
.
fullpath
.
gsub
(
%r{/
#{
path
}
/*}
,
"/-/
#{
path
}
/"
)
},
as:
"legacy_
#{
path
}
_redirect"
end
end
end
end
spec/support/legacy_path_redirect_shared_examples.rb
0 → 100644
View file @
414c4e3f
shared_examples
'redirecting a legacy path'
do
|
source
,
target
|
include
RSpec
::
Rails
::
RequestExampleGroup
it
"redirects
#{
source
}
to
#{
target
}
when the resource does not exist"
do
expect
(
get
(
source
)).
to
redirect_to
(
target
)
end
it
"does not redirect
#{
source
}
to
#{
target
}
when the resource exists"
do
resource
expect
(
get
(
source
)).
not_to
redirect_to
(
target
)
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