Commit 56cb598e authored by Drew Blessing's avatar Drew Blessing Committed by Dmytro Zaporozhets (DZ)

Redirect deprecated profile paths to scoped path

Redirect previously deprecated profile paths to the new scoped /-/
routes.
parent ee96f8b7
---
title: Redirect deprecated profile paths to scoped path
merge_request: 51646
author:
type: changed
......@@ -279,7 +279,8 @@ Rails.application.routes.draw do
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/210024
scope as: 'deprecated' do
draw :snippets
draw :profile
Gitlab::Routing.redirect_legacy_paths(self, :profile)
end
Gitlab.ee do
......
......@@ -43,7 +43,7 @@ RSpec.describe "Dashboard access" do
it { expect(new_group_path).to be_allowed_for :auditor }
end
describe "GET /profile/groups" do
describe "GET /dashboard/groups" do
subject { dashboard_groups_path }
it { is_expected.to be_allowed_for :auditor }
......
......@@ -5,37 +5,37 @@ require 'spec_helper'
RSpec.describe "Profile access" do
include AccessMatchers
describe "GET /profile/keys" do
describe "GET /-/profile/keys" do
subject { profile_keys_path }
it { is_expected.to be_allowed_for :auditor }
end
describe "GET /profile" do
describe "GET /-/profile" do
subject { profile_path }
it { is_expected.to be_allowed_for :auditor }
end
describe "GET /profile/account" do
describe "GET /-/profile/account" do
subject { profile_account_path }
it { is_expected.to be_allowed_for :auditor }
end
describe "GET /profile/preferences" do
describe "GET /-/profile/preferences" do
subject { profile_preferences_path }
it { is_expected.to be_allowed_for :auditor }
end
describe "GET /profile/audit_log" do
describe "GET /-/profile/audit_log" do
subject { audit_log_profile_path }
it { is_expected.to be_allowed_for :auditor }
end
describe "GET /profile/notifications" do
describe "GET /-/profile/notifications" do
subject { profile_notifications_path }
it { is_expected.to be_allowed_for :auditor }
......
......@@ -30,7 +30,7 @@ RSpec.describe 'EE-specific project routing' do
end
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/vulnerability_feedback", "/gitlab/gitlabhq/-/vulnerability_feedback"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/vulnerability_feedback", "/gitlab/gitlabhq/-/vulnerability_feedback"
end
end
......@@ -49,13 +49,13 @@ RSpec.describe 'EE-specific project routing' do
describe Projects::ProtectedEnvironmentsController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/protected_environments", "/gitlab/gitlabhq/-/protected_environments"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/protected_environments", "/gitlab/gitlabhq/-/protected_environments"
end
end
describe Projects::AuditEventsController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/audit_events", "/gitlab/gitlabhq/-/audit_events"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/audit_events", "/gitlab/gitlabhq/-/audit_events"
end
end
......
......@@ -57,7 +57,7 @@ RSpec.describe "Dashboard access" do
it { expect(new_group_path).to be_denied_for :visitor }
end
describe "GET /profile/groups" do
describe "GET /dashboard/groups" do
subject { dashboard_groups_path }
it { is_expected.to be_allowed_for :admin }
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe "Profile access" do
include AccessMatchers
describe "GET /profile/keys" do
describe "GET /-/profile/keys" do
subject { profile_keys_path }
it { is_expected.to be_allowed_for :admin }
......@@ -13,7 +13,7 @@ RSpec.describe "Profile access" do
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile" do
describe "GET /-/profile" do
subject { profile_path }
it { is_expected.to be_allowed_for :admin }
......@@ -21,7 +21,7 @@ RSpec.describe "Profile access" do
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/account" do
describe "GET /-/profile/account" do
subject { profile_account_path }
it { is_expected.to be_allowed_for :admin }
......@@ -29,7 +29,7 @@ RSpec.describe "Profile access" do
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/preferences" do
describe "GET /-/profile/preferences" do
subject { profile_preferences_path }
it { is_expected.to be_allowed_for :admin }
......@@ -37,7 +37,7 @@ RSpec.describe "Profile access" do
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/audit_log" do
describe "GET /-/profile/audit_log" do
subject { audit_log_profile_path }
it { is_expected.to be_allowed_for :admin }
......@@ -45,7 +45,7 @@ RSpec.describe "Profile access" do
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/notifications" do
describe "GET /-/profile/notifications" do
subject { profile_notifications_path }
it { is_expected.to be_allowed_for :admin }
......
......@@ -102,6 +102,7 @@ RSpec.describe Gitlab::PathRegex do
.concat(files_in_public)
.concat(Array(API::API.prefix.to_s))
.concat(sitemap_words)
.concat(deprecated_routes)
.compact
.uniq
end
......@@ -110,6 +111,11 @@ RSpec.describe Gitlab::PathRegex do
%w(sitemap sitemap.xml sitemap.xml.gz)
end
let(:deprecated_routes) do
# profile was deprecated in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51646
%w(profile)
end
let(:ee_top_level_words) do
%w(unsubscribes v2)
end
......
......@@ -24,7 +24,7 @@ RSpec.describe 'view user notifications' do
get profile_notifications_path
end
describe 'GET /profile/notifications' do
describe 'GET /-/profile/notifications' do
it 'does not have an N+1 due to an additional groups (with no parent group)' do
get_profile_notifications
......
......@@ -4,15 +4,15 @@ require "spec_helper"
RSpec.describe "notifications routing" do
it "routes to #show" do
expect(get("/profile/notifications")).to route_to("profiles/notifications#show")
expect(get("/-/profile/notifications")).to route_to("profiles/notifications#show")
end
it "routes to #update" do
expect(put("/profile/notifications")).to route_to("profiles/notifications#update")
expect(put("/-/profile/notifications")).to route_to("profiles/notifications#update")
end
it 'routes to group #update' do
expect(put("/profile/notifications/groups/gitlab-org")).to route_to("profiles/groups#update", id: 'gitlab-org')
expect(put("/profile/notifications/groups/gitlab.org")).to route_to("profiles/groups#update", id: 'gitlab.org')
expect(put("/-/profile/notifications/groups/gitlab-org")).to route_to("profiles/groups#update", id: 'gitlab-org')
expect(put("/-/profile/notifications/groups/gitlab.org")).to route_to("profiles/groups#update", id: 'gitlab.org')
end
end
......@@ -106,8 +106,8 @@ RSpec.describe 'project routing' do
let(:base_path) { '/gitlab/gitlabhq/-/wikis' }
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/wikis", "/gitlab/gitlabhq/-/wikis"
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/wikis/home/edit", "/gitlab/gitlabhq/-/wikis/home/edit"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/wikis", "/gitlab/gitlabhq/-/wikis"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/wikis/home/edit", "/gitlab/gitlabhq/-/wikis/home/edit"
end
# branches_project_repository GET /:project_id/repository/branches(.:format) projects/repositories#branches
......@@ -171,7 +171,7 @@ RSpec.describe 'project routing' do
expect(delete('/gitlab/gitlabhq/-/tags/feature@45/foo/bar/baz')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45/foo/bar/baz')
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/tags", "/gitlab/gitlabhq/-/tags"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/tags", "/gitlab/gitlabhq/-/tags"
end
# project_deploy_keys GET /:project_id/deploy_keys(.:format) deploy_keys#index
......@@ -259,8 +259,8 @@ RSpec.describe 'project routing' do
let(:base_path) { '/gitlab/gitlabhq/-/merge_requests' }
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/merge_requests", "/gitlab/gitlabhq/-/merge_requests"
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/merge_requests/1/diffs", "/gitlab/gitlabhq/-/merge_requests/1/diffs"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/merge_requests", "/gitlab/gitlabhq/-/merge_requests"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/merge_requests/1/diffs", "/gitlab/gitlabhq/-/merge_requests/1/diffs"
end
describe Projects::MergeRequests::CreationsController, 'routing' do
......@@ -290,7 +290,7 @@ RSpec.describe 'project routing' do
expect(get('/gitlab/gitlabhq/-/merge_requests/new/diffs.json')).to route_to('projects/merge_requests/creations#diffs', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'json')
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/merge_requests/new", "/gitlab/gitlabhq/-/merge_requests/new"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/merge_requests/new", "/gitlab/gitlabhq/-/merge_requests/new"
end
describe Projects::MergeRequests::DiffsController, 'routing' do
......@@ -454,8 +454,8 @@ RSpec.describe 'project routing' do
let(:base_path) { '/gitlab/gitlabhq/-/issues' }
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/issues", "/gitlab/gitlabhq/-/issues"
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/issues/1/edit", "/gitlab/gitlabhq/-/issues/1/edit"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/issues", "/gitlab/gitlabhq/-/issues"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/issues/1/edit", "/gitlab/gitlabhq/-/issues/1/edit"
end
# project_noteable_notes GET /:project_id/noteable/:target_type/:target_id/notes notes#index
......@@ -769,25 +769,25 @@ RSpec.describe 'project routing' do
describe Projects::EnvironmentsController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/environments", "/gitlab/gitlabhq/-/environments"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/environments", "/gitlab/gitlabhq/-/environments"
end
end
describe Projects::ClustersController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/clusters", "/gitlab/gitlabhq/-/clusters"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/clusters", "/gitlab/gitlabhq/-/clusters"
end
end
describe Projects::ErrorTrackingController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/error_tracking", "/gitlab/gitlabhq/-/error_tracking"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/error_tracking", "/gitlab/gitlabhq/-/error_tracking"
end
end
describe Projects::Serverless, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/serverless", "/gitlab/gitlabhq/-/serverless"
it_behaves_like 'redirecting a legacy path', "/gitlab/gitlabhq/serverless", "/gitlab/gitlabhq/-/serverless"
end
end
......
......@@ -122,111 +122,115 @@ RSpec.describe HelpController, "routing" do
end
end
# profile_account GET /profile/account(.:format) profile#account
# profile_history GET /profile/history(.:format) profile#history
# profile_password PUT /profile/password(.:format) profile#password_update
# profile_token GET /profile/token(.:format) profile#token
# profile GET /profile(.:format) profile#show
# profile_update PUT /profile/update(.:format) profile#update
# profile_account GET /-/profile/account(.:format) profile#account
# profile_history GET /-/profile/history(.:format) profile#history
# profile_password PUT /-/profile/password(.:format) profile#password_update
# profile_token GET /-/profile/token(.:format) profile#token
# profile GET /-/profile(.:format) profile#show
# profile_update PUT /-/profile/update(.:format) profile#update
RSpec.describe ProfilesController, "routing" do
it "to #account" do
expect(get("/profile/account")).to route_to('profiles/accounts#show')
expect(get("/-/profile/account")).to route_to('profiles/accounts#show')
end
it_behaves_like 'redirecting a legacy path', '/profile/account', '/-/profile/account'
it "to #audit_log" do
expect(get("/profile/audit_log")).to route_to('profiles#audit_log')
expect(get("/-/profile/audit_log")).to route_to('profiles#audit_log')
end
it_behaves_like 'redirecting a legacy path', '/profile/audit_log', '/-/profile/audit_log'
it "to #reset_feed_token" do
expect(put("/profile/reset_feed_token")).to route_to('profiles#reset_feed_token')
expect(put("/-/profile/reset_feed_token")).to route_to('profiles#reset_feed_token')
end
it "to #show" do
expect(get("/profile")).to route_to('profiles#show')
end
it 'to #show from scope routing' do
expect(get("/-/profile")).to route_to('profiles#show')
end
it_behaves_like 'redirecting a legacy path', '/profile', '/-/profile'
end
# profile_preferences GET /profile/preferences(.:format) profiles/preferences#show
# PATCH /profile/preferences(.:format) profiles/preferences#update
# PUT /profile/preferences(.:format) profiles/preferences#update
# profile_preferences GET /-/profile/preferences(.:format) profiles/preferences#show
# PATCH /-/profile/preferences(.:format) profiles/preferences#update
# PUT /-/profile/preferences(.:format) profiles/preferences#update
RSpec.describe Profiles::PreferencesController, 'routing' do
it 'to #show' do
expect(get('/profile/preferences')).to route_to('profiles/preferences#show')
expect(get('/-/profile/preferences')).to route_to('profiles/preferences#show')
end
it_behaves_like 'redirecting a legacy path', '/profile/preferences', '/-/profile/preferences'
it 'to #update' do
expect(put('/profile/preferences')).to route_to('profiles/preferences#update')
expect(patch('/profile/preferences')).to route_to('profiles/preferences#update')
expect(put('/-/profile/preferences')).to route_to('profiles/preferences#update')
expect(patch('/-/profile/preferences')).to route_to('profiles/preferences#update')
end
end
# keys GET /keys(.:format) keys#index
# POST /keys(.:format) keys#create
# edit_key GET /keys/:id/edit(.:format) keys#edit
# key GET /keys/:id(.:format) keys#show
# PUT /keys/:id(.:format) keys#update
# DELETE /keys/:id(.:format) keys#destroy
# keys GET /-/profile/keys(.:format) keys#index
# POST /-/profile/keys(.:format) keys#create
# edit_key GET /-/profile/keys/:id/edit(.:format) keys#edit
# key GET /-/profile/keys/:id(.:format) keys#show
# PUT /-/profile/keys/:id(.:format) keys#update
# DELETE /-/profile/keys/:id(.:format) keys#destroy
RSpec.describe Profiles::KeysController, "routing" do
it "to #index" do
expect(get("/profile/keys")).to route_to('profiles/keys#index')
expect(get("/-/profile/keys")).to route_to('profiles/keys#index')
end
it_behaves_like 'redirecting a legacy path', '/profile/keys', '/-/profile/keys'
it "to #create" do
expect(post("/profile/keys")).to route_to('profiles/keys#create')
expect(post("/-/profile/keys")).to route_to('profiles/keys#create')
end
it "to #show" do
expect(get("/profile/keys/1")).to route_to('profiles/keys#show', id: '1')
expect(get("/-/profile/keys/1")).to route_to('profiles/keys#show', id: '1')
end
it_behaves_like 'redirecting a legacy path', '/profile/keys/1', '/-/profile/keys/1'
it "to #destroy" do
expect(delete("/profile/keys/1")).to route_to('profiles/keys#destroy', id: '1')
expect(delete("/-/profile/keys/1")).to route_to('profiles/keys#destroy', id: '1')
end
end
# keys GET /gpg_keys gpg_keys#index
# key POST /gpg_keys gpg_keys#create
# PUT /gpg_keys/:id gpg_keys#revoke
# DELETE /gpg_keys/:id gpg_keys#desroy
# keys GET /-/profile/gpg_keys gpg_keys#index
# key POST /-/profile/gpg_keys gpg_keys#create
# PUT /-/profile/gpg_keys/:id gpg_keys#revoke
# DELETE /-/profile/gpg_keys/:id gpg_keys#desroy
RSpec.describe Profiles::GpgKeysController, "routing" do
it "to #index" do
expect(get("/profile/gpg_keys")).to route_to('profiles/gpg_keys#index')
expect(get("/-/profile/gpg_keys")).to route_to('profiles/gpg_keys#index')
end
it_behaves_like 'redirecting a legacy path', '/profile/gpg_keys', '/-/profile/gpg_keys'
it "to #create" do
expect(post("/profile/gpg_keys")).to route_to('profiles/gpg_keys#create')
expect(post("/-/profile/gpg_keys")).to route_to('profiles/gpg_keys#create')
end
it "to #destroy" do
expect(delete("/profile/gpg_keys/1")).to route_to('profiles/gpg_keys#destroy', id: '1')
expect(delete("/-/profile/gpg_keys/1")).to route_to('profiles/gpg_keys#destroy', id: '1')
end
end
# emails GET /emails(.:format) emails#index
# POST /keys(.:format) emails#create
# DELETE /keys/:id(.:format) keys#destroy
# emails GET /-/profile/emails(.:format) emails#index
# POST /-/profile/emails(.:format) emails#create
# DELETE /-/profile/emails/:id(.:format) keys#destroy
RSpec.describe Profiles::EmailsController, "routing" do
it "to #index" do
expect(get("/profile/emails")).to route_to('profiles/emails#index')
expect(get("/-/profile/emails")).to route_to('profiles/emails#index')
end
it_behaves_like 'redirecting a legacy path', '/profile/emails', '/-/profile/emails'
it "to #create" do
expect(post("/profile/emails")).to route_to('profiles/emails#create')
expect(post("/-/profile/emails")).to route_to('profiles/emails#create')
end
it "to #destroy" do
expect(delete("/profile/emails/1")).to route_to('profiles/emails#destroy', id: '1')
expect(delete("/-/profile/emails/1")).to route_to('profiles/emails#destroy', id: '1')
end
end
# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy
# profile_avatar DELETE /-/profile/avatar(.:format) profiles/avatars#destroy
RSpec.describe Profiles::AvatarsController, "routing" do
it "to #destroy" do
expect(delete("/profile/avatar")).to route_to('profiles/avatars#destroy')
expect(delete("/-/profile/avatar")).to route_to('profiles/avatars#destroy')
end
end
......
# frozen_string_literal: true
RSpec.shared_examples 'redirecting a legacy project path' do |source, target|
RSpec.shared_examples 'redirecting a legacy path' do |source, target|
include RSpec::Rails::RequestExampleGroup
it "redirects #{source} to #{target}" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment