Merge branch '38060-fix-groups-api-owned-groups' into 'master'

Fix the groups API endpoint to handle ?owned=true correctly

Closes #38060

See merge request gitlab-org/gitlab-ce!14362
This commit is contained in:
Douwe Maan 2017-09-19 13:47:14 +00:00
commit a31504497e
2 changed files with 4 additions and 1 deletions

View File

@ -57,7 +57,7 @@ class GroupsFinder < UnionFinder
end
def owned_groups
current_user&.groups || Group.none
current_user&.owned_groups || Group.none
end
def include_public_groups?

View File

@ -159,11 +159,14 @@ describe API::Groups do
context 'when using owned in the request' do
it 'returns an array of groups the user owns' do
group1.add_master(user2)
get api('/groups', user2), owned: true
expect(response).to have_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
expect(json_response.first['name']).to eq(group2.name)
end
end