Commit 050f57d9 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '34261-service-desk-to-api' into 'master'

Expose service desk information in project api

See merge request gitlab-org/gitlab!20913
parents a7055bef 2692b2a2
---
title: Add service desk information to projects API endpoint
merge_request: 20913
author:
type: changed
......@@ -241,6 +241,19 @@ When the user is authenticated and `simple` is not set this returns something li
"remove_source_branch_after_merge": false,
"request_access_enabled": false,
"merge_method": "merge",
"auto_devops_enabled": true,
"auto_devops_deploy_strategy": "continuous",
"repository_storage": "default",
"approvals_before_merge": 0,
"mirror": false,
"mirror_user_id": 45,
"mirror_trigger_builds": false,
"only_mirror_protected_branches": false,
"mirror_overwrites_diverged_branches": false,
"external_authorization_classification_label": null,
"packages_enabled": true,
"service_desk_enabled": false,
"service_desk_address": null,
"statistics": {
"commit_count": 12,
"storage_size": 2066080,
......@@ -457,6 +470,19 @@ This endpoint supports [keyset pagination](README.md#keyset-based-pagination) fo
"remove_source_branch_after_merge": false,
"request_access_enabled": false,
"merge_method": "merge",
"auto_devops_enabled": true,
"auto_devops_deploy_strategy": "continuous",
"repository_storage": "default",
"approvals_before_merge": 0,
"mirror": false,
"mirror_user_id": 45,
"mirror_trigger_builds": false,
"only_mirror_protected_branches": false,
"mirror_overwrites_diverged_branches": false,
"external_authorization_classification_label": null,
"packages_enabled": true,
"service_desk_enabled": false,
"service_desk_address": null,
"statistics": {
"commit_count": 12,
"storage_size": 2066080,
......@@ -649,6 +675,19 @@ Example response:
"remove_source_branch_after_merge": false,
"request_access_enabled": false,
"merge_method": "merge",
"auto_devops_enabled": true,
"auto_devops_deploy_strategy": "continuous",
"repository_storage": "default",
"approvals_before_merge": 0,
"mirror": false,
"mirror_user_id": 45,
"mirror_trigger_builds": false,
"only_mirror_protected_branches": false,
"mirror_overwrites_diverged_branches": false,
"external_authorization_classification_label": null,
"packages_enabled": true,
"service_desk_enabled": false,
"service_desk_address": null,
"statistics": {
"commit_count": 12,
"storage_size": 2066080,
......@@ -777,6 +816,19 @@ GET /projects/:id
"printing_merge_requests_link_enabled": true,
"request_access_enabled": false,
"merge_method": "merge",
"auto_devops_enabled": true,
"auto_devops_deploy_strategy": "continuous",
"repository_storage": "default",
"approvals_before_merge": 0,
"mirror": false,
"mirror_user_id": 45,
"mirror_trigger_builds": false,
"only_mirror_protected_branches": false,
"mirror_overwrites_diverged_branches": false,
"external_authorization_classification_label": null,
"packages_enabled": true,
"service_desk_enabled": false,
"service_desk_address": null,
"statistics": {
"commit_count": 37,
"storage_size": 1038090,
......
......@@ -44,6 +44,8 @@ module EE
expose :external_authorization_classification_label,
if: ->(_, _) { License.feature_available?(:external_authorization_service_api_management) }
expose :packages_enabled, if: ->(project, _) { project.feature_available?(:packages) }
expose :service_desk_enabled, if: ->(project, _) { project.feature_available?(:service_desk) }
expose :service_desk_address, if: ->(project, _) { project.feature_available?(:service_desk) }
end
end
......
......@@ -143,7 +143,7 @@ describe API::Projects do
end
describe 'packages_enabled attribute' do
it 'exposed when the feature is available' do
it 'is exposed when the feature is available' do
stub_licensed_features(packages: true)
get api("/projects/#{project.id}", user)
......@@ -151,7 +151,7 @@ describe API::Projects do
expect(json_response).to have_key 'packages_enabled'
end
it 'not exposed when the feature is available' do
it 'is not exposed when the feature is not available' do
stub_licensed_features(packages: false)
get api("/projects/#{project.id}", user)
......@@ -160,6 +160,26 @@ describe API::Projects do
end
end
describe 'service desk attributes' do
it 'are exposed when the feature is available' do
stub_licensed_features(service_desk: true)
get api("/projects/#{project.id}", user)
expect(json_response).to have_key 'service_desk_enabled'
expect(json_response).to have_key 'service_desk_address'
end
it 'are not exposed when the feature is not available' do
stub_licensed_features(service_desk: false)
get api("/projects/#{project.id}", user)
expect(json_response).not_to have_key 'service_desk_enabled'
expect(json_response).not_to have_key 'service_desk_address'
end
end
describe 'repository_storage attribute' do
context 'when authenticated as an admin' do
let(:admin) { create(:admin) }
......
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