Commit fffce276 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'rs-admin-user-case-insensitive' into 'master'

Admin section finds users case-insensitively

Closes #55877

See merge request gitlab-org/gitlab-ce!25176
parents 32c91331 12c70e63
# frozen_string_literal: true # frozen_string_literal: true
class Admin::UsersController < Admin::ApplicationController class Admin::UsersController < Admin::ApplicationController
include RoutableActions
before_action :user, except: [:index, :new, :create] before_action :user, except: [:index, :new, :create]
before_action :check_impersonation_availability, only: :impersonate before_action :check_impersonation_availability, only: :impersonate
...@@ -177,11 +179,13 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -177,11 +179,13 @@ class Admin::UsersController < Admin::ApplicationController
user == current_user user == current_user
end end
# rubocop: disable CodeReuse/ActiveRecord
def user def user
@user ||= User.find_by!(username: params[:id]) @user ||= find_routable!(User, params[:id])
end
def build_canonical_path(user)
url_for(safe_params.merge(id: user.to_param))
end end
# rubocop: enable CodeReuse/ActiveRecord
def redirect_back_or_admin_user(options = {}) def redirect_back_or_admin_user(options = {})
redirect_back_or_default(default: default_route, options: options) redirect_back_or_default(default: default_route, options: options)
......
---
title: Admin section finds users case-insensitively
merge_request:
author:
type: fixed
...@@ -8,6 +8,17 @@ describe Admin::UsersController do ...@@ -8,6 +8,17 @@ describe Admin::UsersController do
sign_in(admin) sign_in(admin)
end end
describe 'GET :id' do
it 'finds a user case-insensitively' do
user = create(:user, username: 'CaseSensitive')
get :show, params: { id: user.username.downcase }
expect(response).to be_redirect
expect(response.location).to end_with(user.username)
end
end
describe 'DELETE #user with projects' do describe 'DELETE #user with projects' do
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, namespace: user.namespace) }
let!(:issue) { create(:issue, author: user) } let!(:issue) { create(:issue, author: 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