diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-09-19 13:47:14 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-09-19 13:47:14 +0000 |
commit | a31504497e51218884fb5bdeb71e5aba73057159 (patch) | |
tree | b48071f8046e93298e82e67a519f6dc5cc46b805 | |
parent | 0cd46457bdbe3cf36421755dab8b59d830d77b62 (diff) | |
parent | 47cf3b4b6178b75cc39dbe74c0701e6a44b26fe4 (diff) | |
download | gitlab-ce-a31504497e51218884fb5bdeb71e5aba73057159.tar.gz |
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
-rw-r--r-- | app/finders/groups_finder.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/groups_spec.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb index 88d71b0a87b..0c4c4b10fb6 100644 --- a/app/finders/groups_finder.rb +++ b/app/finders/groups_finder.rb @@ -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? diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 42f0079e173..1671a046fdf 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -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 |