Commit d70b7a49 authored by Tiago Botelho's avatar Tiago Botelho

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

parent 4d88f649
---
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 ...@@ -11,7 +11,7 @@ module API
end end
helpers do helpers do
def find_user(params) def find_user_by_id(params)
id = params[:user_id] || params[:id] id = params[:user_id] || params[:id]
User.find_by(id: id) || not_found!('User') User.find_by(id: id) || not_found!('User')
end end
...@@ -430,7 +430,7 @@ module API ...@@ -430,7 +430,7 @@ module API
resource :impersonation_tokens do resource :impersonation_tokens do
helpers do helpers do
def finder(options = {}) def finder(options = {})
user = find_user(params) user = find_user_by_id(params)
PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options)) PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
end end
......
...@@ -125,6 +125,15 @@ describe API::Users do ...@@ -125,6 +125,15 @@ describe API::Users do
end end
context "when admin" do 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 it "returns an array of users" do
get api("/users", admin) 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