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
Jérome Perrin
gitlab-ce
Commits
e4bcc90d
Commit
e4bcc90d
authored
May 04, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add “project moved” flash message on redirect
parent
0c866f4a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
0 deletions
+9
-0
app/controllers/concerns/routable_actions.rb
app/controllers/concerns/routable_actions.rb
+1
-0
spec/controllers/groups_controller_spec.rb
spec/controllers/groups_controller_spec.rb
+2
-0
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+2
-0
spec/controllers/users_controller_spec.rb
spec/controllers/users_controller_spec.rb
+4
-0
No files found.
app/controllers/concerns/routable_actions.rb
View file @
e4bcc90d
...
@@ -5,6 +5,7 @@ module RoutableActions
...
@@ -5,6 +5,7 @@ module RoutableActions
return
unless
request
.
get?
return
unless
request
.
get?
if
routable
.
full_path
!=
requested_path
if
routable
.
full_path
!=
requested_path
flash
[
:notice
]
=
'This project has moved to this location. Please update your links and bookmarks.'
redirect_to
request
.
original_url
.
sub
(
requested_path
,
routable
.
full_path
)
redirect_to
request
.
original_url
.
sub
(
requested_path
,
routable
.
full_path
)
end
end
end
end
...
...
spec/controllers/groups_controller_spec.rb
View file @
e4bcc90d
...
@@ -65,6 +65,7 @@ describe GroupsController do
...
@@ -65,6 +65,7 @@ describe GroupsController do
get
:issues
,
id:
redirect_route
.
path
get
:issues
,
id:
redirect_route
.
path
expect
(
response
).
to
redirect_to
(
issues_group_path
(
group
.
to_param
))
expect
(
response
).
to
redirect_to
(
issues_group_path
(
group
.
to_param
))
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/moved/
)
end
end
end
end
end
end
...
@@ -108,6 +109,7 @@ describe GroupsController do
...
@@ -108,6 +109,7 @@ describe GroupsController do
get
:merge_requests
,
id:
redirect_route
.
path
get
:merge_requests
,
id:
redirect_route
.
path
expect
(
response
).
to
redirect_to
(
merge_requests_group_path
(
group
.
to_param
))
expect
(
response
).
to
redirect_to
(
merge_requests_group_path
(
group
.
to_param
))
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/moved/
)
end
end
end
end
end
end
...
...
spec/controllers/projects_controller_spec.rb
View file @
e4bcc90d
...
@@ -226,6 +226,7 @@ describe ProjectsController do
...
@@ -226,6 +226,7 @@ describe ProjectsController do
get
:show
,
namespace_id:
'foo'
,
id:
'bar'
get
:show
,
namespace_id:
'foo'
,
id:
'bar'
expect
(
response
).
to
redirect_to
(
public_project
)
expect
(
response
).
to
redirect_to
(
public_project
)
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/moved/
)
end
end
end
end
end
end
...
@@ -471,6 +472,7 @@ describe ProjectsController do
...
@@ -471,6 +472,7 @@ describe ProjectsController do
get
:refs
,
namespace_id:
'foo'
,
id:
'bar'
get
:refs
,
namespace_id:
'foo'
,
id:
'bar'
expect
(
response
).
to
redirect_to
(
refs_namespace_project_path
(
namespace_id:
public_project
.
namespace
,
id:
public_project
))
expect
(
response
).
to
redirect_to
(
refs_namespace_project_path
(
namespace_id:
public_project
.
namespace
,
id:
public_project
))
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/moved/
)
end
end
end
end
end
end
...
...
spec/controllers/users_controller_spec.rb
View file @
e4bcc90d
...
@@ -82,6 +82,7 @@ describe UsersController do
...
@@ -82,6 +82,7 @@ describe UsersController do
get
:show
,
username:
redirect_route
.
path
get
:show
,
username:
redirect_route
.
path
expect
(
response
).
to
redirect_to
(
user
)
expect
(
response
).
to
redirect_to
(
user
)
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/moved/
)
end
end
end
end
...
@@ -159,6 +160,7 @@ describe UsersController do
...
@@ -159,6 +160,7 @@ describe UsersController do
get
:calendar
,
username:
redirect_route
.
path
get
:calendar
,
username:
redirect_route
.
path
expect
(
response
).
to
redirect_to
(
user_calendar_path
(
user
))
expect
(
response
).
to
redirect_to
(
user_calendar_path
(
user
))
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/moved/
)
end
end
end
end
end
end
...
@@ -211,6 +213,7 @@ describe UsersController do
...
@@ -211,6 +213,7 @@ describe UsersController do
get
:calendar_activities
,
username:
redirect_route
.
path
get
:calendar_activities
,
username:
redirect_route
.
path
expect
(
response
).
to
redirect_to
(
user_calendar_activities_path
(
user
))
expect
(
response
).
to
redirect_to
(
user_calendar_activities_path
(
user
))
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/moved/
)
end
end
end
end
end
end
...
@@ -263,6 +266,7 @@ describe UsersController do
...
@@ -263,6 +266,7 @@ describe UsersController do
get
:snippets
,
username:
redirect_route
.
path
get
:snippets
,
username:
redirect_route
.
path
expect
(
response
).
to
redirect_to
(
user_snippets_path
(
user
))
expect
(
response
).
to
redirect_to
(
user_snippets_path
(
user
))
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
/moved/
)
end
end
end
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