summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-05-11 13:57:03 -0700
committerMichael Kozono <mkozono@gmail.com>2017-05-11 15:01:10 -0700
commit23ff638c2fe391c99cc9305d83c0f48b68028c1e (patch)
tree4a227103f2bde344e4ae17f0dd61a3fa987845b5
parente7e132529bff3af38175076b84c818b6dea4b05f (diff)
downloadgitlab-ce-mk-fix-routable-redirect-message.tar.gz
Fix redirect message for groups and usersmk-fix-routable-redirect-message
-rw-r--r--app/controllers/concerns/routable_actions.rb2
-rw-r--r--spec/controllers/groups_controller_spec.rb8
-rw-r--r--spec/controllers/projects_controller_spec.rb8
-rw-r--r--spec/controllers/users_controller_spec.rb12
4 files changed, 21 insertions, 9 deletions
diff --git a/app/controllers/concerns/routable_actions.rb b/app/controllers/concerns/routable_actions.rb
index d4ab6782444..24456d16e81 100644
--- a/app/controllers/concerns/routable_actions.rb
+++ b/app/controllers/concerns/routable_actions.rb
@@ -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
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb
index df8ea225814..15dae3231ca 100644
--- a/spec/controllers/groups_controller_spec.rb
+++ b/spec/controllers/groups_controller_spec.rb
@@ -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
@@ -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
@@ -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
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index e46ef447df2..e230944d52e 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -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
@@ -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
@@ -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
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 74c5aa44ba9..1d61719f1d0 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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