Commit ee66b5b6 authored by Luke Duncalfe's avatar Luke Duncalfe

Remove unused UsersController#suggests

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57563 replaced the
functionality of namespace suggestion checking with an API endpoint.

https://gitlab.com/gitlab-org/gitlab/-/issues/327807
parent 026957b9
......@@ -20,7 +20,7 @@ class UsersController < ApplicationController
skip_before_action :authenticate_user!
prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) }
before_action :user, except: [:exists, :suggests, :ssh_keys]
before_action :user, except: [:exists, :ssh_keys]
before_action :authorize_read_user_profile!,
only: [:calendar, :calendar_activities, :groups, :projects, :contributed, :starred, :snippets, :followers, :following]
......@@ -153,14 +153,6 @@ class UsersController < ApplicationController
render json: { exists: !!Namespace.find_by_path_or_name(params[:username]) }
end
def suggests
namespace_path = params[:username]
exists = !!Namespace.find_by_path_or_name(namespace_path)
suggestions = exists ? [Namespace.clean_path(namespace_path)] : []
render json: { exists: exists, suggests: suggestions }
end
def follow
current_user.follow(user)
......
......@@ -49,7 +49,6 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d
get :followers
get :following
get :exists
get :suggests
get :activity
post :follow
post :unfollow
......
......@@ -675,48 +675,6 @@ RSpec.describe UsersController do
end
end
describe 'GET #suggests' do
context 'when user exists' do
it 'returns JSON indicating the user exists and a suggestion' do
get user_suggests_url user.username
expected_json = { exists: true, suggests: ["#{user.username}1"] }.to_json
expect(response.body).to eq(expected_json)
end
context 'when the casing is different' do
let(:user) { create(:user, username: 'CamelCaseUser') }
it 'returns JSON indicating the user exists and a suggestion' do
get user_suggests_url user.username.downcase
expected_json = { exists: true, suggests: ["#{user.username.downcase}1"] }.to_json
expect(response.body).to eq(expected_json)
end
end
end
context 'when the user does not exist' do
it 'returns JSON indicating the user does not exist' do
get user_suggests_url 'foo'
expected_json = { exists: false, suggests: [] }.to_json
expect(response.body).to eq(expected_json)
end
context 'when a user changed their username' do
let(:redirect_route) { user.namespace.redirect_routes.create!(path: 'old-username') }
it 'returns JSON indicating a user by that username does not exist' do
get user_suggests_url 'old-username'
expected_json = { exists: false, suggests: [] }.to_json
expect(response.body).to eq(expected_json)
end
end
end
end
describe '#ensure_canonical_path' do
before do
sign_in(user)
......
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