Skip to content
Snippets Groups Projects
Commit 61f811e6 authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch 'mk-fix-routable-redirect-message' into 'master'

Fix redirect message for groups and users

See merge request !11313
parents b4b7cf5a ab98f8b5
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4,7 +4,7 @@ module RoutableActions
def find_routable!(routable_klass, requested_full_path, extra_authorization_proc: nil)
routable = routable_klass.find_by_full_path(requested_full_path, follow_redirects: request.get?)
 
if routable_authorized?(routable_klass, routable, extra_authorization_proc)
if routable_authorized?(routable, extra_authorization_proc)
ensure_canonical_path(routable, requested_full_path)
routable
else
Loading
Loading
@@ -13,8 +13,8 @@ module RoutableActions
end
end
 
def routable_authorized?(routable_klass, routable, extra_authorization_proc)
action = :"read_#{routable_klass.to_s.underscore}"
def routable_authorized?(routable, extra_authorization_proc)
action = :"read_#{routable.class.to_s.underscore}"
return false unless can?(current_user, action, routable)
 
if extra_authorization_proc
Loading
Loading
@@ -30,7 +30,7 @@ module RoutableActions
canonical_path = routable.full_path
if canonical_path != requested_path
if canonical_path.casecmp(requested_path) != 0
flash[:notice] = "Project '#{requested_path}' was moved to '#{canonical_path}'. Please update any links and bookmarks that may still have the old path."
flash[:notice] = "#{routable.class.to_s.titleize} '#{requested_path}' was moved to '#{canonical_path}'. Please update any links and bookmarks that may still have the old path."
end
redirect_to request.original_url.sub(requested_path, canonical_path)
end
Loading
Loading
Loading
Loading
@@ -101,7 +101,7 @@ describe GroupsController do
get :issues, id: redirect_route.path
 
expect(response).to redirect_to(issues_group_path(group.to_param))
expect(controller).to set_flash[:notice].to(/moved/)
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
end
end
Loading
Loading
@@ -146,7 +146,7 @@ describe GroupsController do
get :merge_requests, id: redirect_route.path
 
expect(response).to redirect_to(merge_requests_group_path(group.to_param))
expect(controller).to set_flash[:notice].to(/moved/)
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
end
end
Loading
Loading
@@ -249,4 +249,8 @@ describe GroupsController do
end
end
end
def group_moved_message(redirect_route, group)
"Group '#{redirect_route.path}' was moved to '#{group.full_path}'. Please update any links and bookmarks that may still have the old path."
end
end
Loading
Loading
@@ -227,7 +227,7 @@ describe ProjectsController do
get :show, namespace_id: 'foo', id: 'bar'
 
expect(response).to redirect_to(public_project)
expect(controller).to set_flash[:notice].to(/moved/)
expect(controller).to set_flash[:notice].to(project_moved_message(redirect_route, public_project))
end
end
end
Loading
Loading
@@ -473,7 +473,7 @@ describe ProjectsController do
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(controller).to set_flash[:notice].to(/moved/)
expect(controller).to set_flash[:notice].to(project_moved_message(redirect_route, public_project))
end
end
end
Loading
Loading
@@ -487,4 +487,8 @@ describe ProjectsController do
expect(JSON.parse(response.body).keys).to match_array(%w(body references))
end
end
def project_moved_message(redirect_route, project)
"Project '#{redirect_route.path}' was moved to '#{project.full_path}'. Please update any links and bookmarks that may still have the old path."
end
end
Loading
Loading
@@ -83,7 +83,7 @@ describe UsersController do
get :show, username: redirect_route.path
 
expect(response).to redirect_to(user)
expect(controller).to set_flash[:notice].to(/moved/)
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
end
end
 
Loading
Loading
@@ -162,7 +162,7 @@ describe UsersController do
get :calendar, username: redirect_route.path
 
expect(response).to redirect_to(user_calendar_path(user))
expect(controller).to set_flash[:notice].to(/moved/)
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
end
end
end
Loading
Loading
@@ -216,7 +216,7 @@ describe UsersController do
get :calendar_activities, username: redirect_route.path
 
expect(response).to redirect_to(user_calendar_activities_path(user))
expect(controller).to set_flash[:notice].to(/moved/)
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
end
end
end
Loading
Loading
@@ -270,7 +270,7 @@ describe UsersController do
get :snippets, username: redirect_route.path
 
expect(response).to redirect_to(user_snippets_path(user))
expect(controller).to set_flash[:notice].to(/moved/)
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
end
end
end
Loading
Loading
@@ -320,4 +320,8 @@ describe UsersController do
end
end
end
def user_moved_message(redirect_route, user)
"User '#{redirect_route.path}' was moved to '#{user.full_path}'. Please update any links and bookmarks that may still have the old path."
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment