Skip to content
Snippets Groups Projects
Commit 062f5b71 authored by Mark Fletcher's avatar Mark Fletcher
Browse files

Fix error on empty query for Members API

parent ee587631
No related branches found
No related tags found
No related merge requests found
---
title: Fix error on empty query for Members API
merge_request: 16235
author:
type: fixed
Loading
Loading
@@ -22,7 +22,7 @@ module API
source = find_source(source_type, params[:id])
 
users = source.users
users = users.merge(User.search(params[:query])) if params[:query]
users = users.merge(User.search(params[:query])) if params[:query].present?
 
present paginate(users), with: Entities::Member, source: source
end
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ module API
source = find_source(source_type, params[:id])
 
users = source.users
users = users.merge(User.search(params[:query])) if params[:query]
users = users.merge(User.search(params[:query])) if params[:query].present?
 
present paginate(users), with: ::API::Entities::Member, source: source
end
Loading
Loading
Loading
Loading
@@ -65,6 +65,16 @@ describe API::Members do
expect(json_response.count).to eq(1)
expect(json_response.first['username']).to eq(master.username)
end
it 'finds all members with no query specified' do
get api("/#{source_type.pluralize}/#{source.id}/members", developer), query: ''
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.count).to eq(2)
expect(json_response.map { |u| u['id'] }).to match_array [master.id, developer.id]
end
end
end
 
Loading
Loading
Loading
Loading
@@ -58,6 +58,16 @@ describe API::V3::Members do
expect(json_response.count).to eq(1)
expect(json_response.first['username']).to eq(master.username)
end
it 'finds all members with no query specified' do
get v3_api("/#{source_type.pluralize}/#{source.id}/members", developer), query: ''
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.count).to eq(2)
expect(json_response.map { |u| u['id'] }).to match_array [master.id, developer.id]
end
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment