Commit 80e00cb2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'jej/protected-branch-api-includes-user-ids' into 'master'

ProtectedBranch API includes user_id/group_id in access levels

Closes #4152

See merge request gitlab-org/gitlab-ee!3535
parents ca1d1894 8fcbe210
---
title: EE Protected Branches API access levels include user_id/group_id where relevant
merge_request: 3535
author:
type: changed
......@@ -36,13 +36,17 @@ Example response:
"push_access_levels": [
{
"access_level": 40,
"user_id": null,
"group_id": null,
"access_level_description": "Masters"
}
],
"merge_access_levels": [
{
"access_level": 40,
"access_level_description": "Masters"
"access_level": null,
"user_id": null,
"group_id": 1234,
"access_level_description": "Example Merge Group"
}
]
},
......@@ -75,13 +79,17 @@ Example response:
"push_access_levels": [
{
"access_level": 40,
"user_id": null,
"group_id": null,
"access_level_description": "Masters"
}
],
"merge_access_levels": [
{
"access_level": 40,
"access_level_description": "Masters"
"access_level": null,
"user_id": null,
"group_id": 1234,
"access_level_description": "Example Merge Group"
}
]
}
......@@ -115,12 +123,16 @@ Example response:
"push_access_levels": [
{
"access_level": 30,
"user_id": null,
"group_id": null,
"access_level_description": "Developers + Masters"
}
],
"merge_access_levels": [
{
"access_level": 30,
"user_id": null,
"group_id": null,
"access_level_description": "Developers + Masters"
}
]
......
......@@ -341,6 +341,12 @@ module API
class ProtectedRefAccess < Grape::Entity
expose :access_level
## EE-only
expose :user_id
expose :group_id
## EE-only
expose :access_level_description do |protected_ref_access|
protected_ref_access.humanize
end
......
......@@ -66,6 +66,27 @@ describe API::ProtectedBranches do
let(:message) { '404 Not found' }
end
end
context 'with per user/group access levels' do
let(:push_user) { create(:user) }
let(:merge_group) { create(:group) }
before do
protected_branch.push_access_levels.create!(user: push_user)
protected_branch.merge_access_levels.create!(group: merge_group)
end
it 'returns access level details' do
get api(route, user)
push_user_ids = json_response['push_access_levels'].map {|level| level['user_id']}
merge_group_ids = json_response['merge_access_levels'].map {|level| level['group_id']}
expect(response).to have_gitlab_http_status(200)
expect(push_user_ids).to include(push_user.id)
expect(merge_group_ids).to include(merge_group.id)
end
end
end
context 'when authenticated as a master' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment