summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-02-06 16:40:25 +0000
committerDouwe Maan <douwe@gitlab.com>2018-02-06 16:40:25 +0000
commite8e4e3fcbe8d63a06e29f48719d70ee94d220281 (patch)
treec64e6d6be9fbc2bffcab695a9deef272de0228ab /spec/requests
parentf81306e76fa16458d8ea72c2e7edf76af822610d (diff)
parent28ef8cc56ec2f3b48e383050671b9dece58fe039 (diff)
downloadgitlab-ce-e8e4e3fcbe8d63a06e29f48719d70ee94d220281.tar.gz
Merge branch '42669-allow-order_by-users-in-gitlab-api' into 'master'
Add sorting options for /users API Closes #42669 See merge request gitlab-org/gitlab-ce!16945
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/users_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 2428e63e149..f406d2ffb22 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -199,6 +199,24 @@ describe API::Users do
expect(json_response.size).to eq(1)
expect(json_response.first['username']).to eq(user.username)
end
+
+ it 'returns the correct order when sorted by id' do
+ admin
+ user
+
+ get api('/users', admin), { order_by: 'id', sort: 'asc' }
+
+ expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(json_response.size).to eq(2)
+ expect(json_response.first['id']).to eq(admin.id)
+ expect(json_response.last['id']).to eq(user.id)
+ end
+
+ it 'returns 400 when provided incorrect sort params' do
+ get api('/users', admin), { order_by: 'magic', sort: 'asc' }
+
+ expect(response).to have_gitlab_http_status(400)
+ end
end
end