Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
062f5b71
Commit
062f5b71
authored
Jan 04, 2018
by
Mark Fletcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error on empty query for Members API
parent
ee587631
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
2 deletions
+27
-2
changelogs/unreleased/41673-blank-query-members-api.yml
changelogs/unreleased/41673-blank-query-members-api.yml
+5
-0
lib/api/members.rb
lib/api/members.rb
+1
-1
lib/api/v3/members.rb
lib/api/v3/members.rb
+1
-1
spec/requests/api/members_spec.rb
spec/requests/api/members_spec.rb
+10
-0
spec/requests/api/v3/members_spec.rb
spec/requests/api/v3/members_spec.rb
+10
-0
No files found.
changelogs/unreleased/41673-blank-query-members-api.yml
0 → 100644
View file @
062f5b71
---
title
:
Fix error on empty query for Members API
merge_request
:
16235
author
:
type
:
fixed
lib/api/members.rb
View file @
062f5b71
...
...
@@ -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
...
...
lib/api/v3/members.rb
View file @
062f5b71
...
...
@@ -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
...
...
spec/requests/api/members_spec.rb
View file @
062f5b71
...
...
@@ -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
...
...
spec/requests/api/v3/members_spec.rb
View file @
062f5b71
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment