find_user users helper method no longer overrides find_user API helper method.
This commit is contained in:
parent
4d88f64968
commit
d70b7a490d
3 changed files with 16 additions and 2 deletions
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue