Commit da7353d3 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '37467-helper-method-from-users-endpoint-overrides-api-helper-method' into 'master'

find_user users helper method no longer overrides find_user API helper method.

Closes #37467

See merge request gitlab-org/gitlab-ce!14418
parents 74648117 d70b7a49
---
title: find_user Users helper method no longer overrides find_user API helper method.
merge_request: 14418
author:
type: fixed
......@@ -11,7 +11,7 @@ module API
end
helpers do
def find_user(params)
def find_user_by_id(params)
id = params[:user_id] || params[:id]
User.find_by(id: id) || not_found!('User')
end
......@@ -430,7 +430,7 @@ module API
resource :impersonation_tokens do
helpers do
def finder(options = {})
user = find_user(params)
user = find_user_by_id(params)
PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
end
......
......@@ -125,6 +125,15 @@ describe API::Users do
end
context "when admin" do
context 'when sudo is defined' do
it 'does not return 500' do
admin_personal_access_token = create(:personal_access_token, user: admin).token
get api("/users?private_token=#{admin_personal_access_token}&sudo=#{user.id}", admin)
expect(response).to have_http_status(:success)
end
end
it "returns an array of users" do
get api("/users", admin)
......
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