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
c749e95e
Commit
c749e95e
authored
Nov 27, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add packages_enabled attribute to Projects API
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
ae22cb3c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
1 deletion
+62
-1
doc/api/projects.md
doc/api/projects.md
+1
-0
ee/changelogs/unreleased/8492-add-packages_enabled-attribute-to-projects-api.yml
...d/8492-add-packages_enabled-attribute-to-projects-api.yml
+5
-0
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+1
-0
ee/lib/ee/api/projects.rb
ee/lib/ee/api/projects.rb
+3
-1
ee/spec/requests/api/projects_spec.rb
ee/spec/requests/api/projects_spec.rb
+52
-0
No files found.
doc/api/projects.md
View file @
c749e95e
...
...
@@ -780,6 +780,7 @@ PUT /projects/:id
|
`mirror_trigger_builds`
| boolean | no | Pull mirroring triggers builds |
|
`only_mirror_protected_branches`
| boolean | no | Only mirror protected branches |
|
`mirror_overwrites_diverged_branches`
| boolean | no | Pull mirror overwrites diverged branches |
|
`packages_enabled`
| boolean | no | Enable or disable packages repository feature |
>**Note**: If your HTTP repository is not publicly accessible,
add authentication information to the URL:
`https://username:password@gitlab.company.com/group/project.git`
...
...
ee/changelogs/unreleased/8492-add-packages_enabled-attribute-to-projects-api.yml
0 → 100644
View file @
c749e95e
---
title
:
Add packages_enabled attribute to Projects API
merge_request
:
8604
author
:
type
:
changed
ee/lib/ee/api/entities.rb
View file @
c749e95e
...
...
@@ -25,6 +25,7 @@ module EE
expose
:mirror_overwrites_diverged_branches
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:external_authorization_classification_label
,
if:
->
(
_
,
_
)
{
License
.
feature_available?
(
:external_authorization_service
)
}
expose
:packages_enabled
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:packages
)
}
end
end
...
...
ee/lib/ee/api/projects.rb
View file @
c749e95e
...
...
@@ -19,6 +19,7 @@ module EE
optional
:only_mirror_protected_branches
,
type:
Grape
::
API
::
Boolean
,
desc:
'Only mirror protected branches'
optional
:mirror_overwrites_diverged_branches
,
type:
Grape
::
API
::
Boolean
,
desc:
'Pull mirror overwrites diverged branches'
optional
:import_url
,
type:
String
,
desc:
'URL from which the project is imported'
optional
:packages_enabled
,
type:
Grape
::
API
::
Boolean
,
desc:
'Enable project packages feature'
end
def
apply_filters
(
projects
)
...
...
@@ -65,7 +66,8 @@ module EE
:approvals_before_merge
,
:repository_storage
,
:external_authorization_classification_label
,
:import_url
:import_url
,
:packages_enabled
]
end
end
...
...
ee/spec/requests/api/projects_spec.rb
View file @
c749e95e
...
...
@@ -238,6 +238,40 @@ describe API::Projects do
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
describe
'updating packages_enabled attribute'
do
it
'is enabled by default'
do
expect
(
project
.
packages_enabled
).
to
be
true
end
context
'packages feature is allowed by license'
do
before
do
stub_licensed_features
(
packages:
true
)
end
it
'disables project packages feature'
do
put
(
api
(
"/projects/
#{
project
.
id
}
"
,
user
),
packages_enabled:
false
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
project
.
reload
.
packages_enabled
).
to
be
false
expect
(
json_response
[
'packages_enabled'
]).
to
eq
(
false
)
end
end
context
'packages feature is not allowed by license'
do
before
do
stub_licensed_features
(
packages:
false
)
end
it
'disables project packages feature but does not return packages_enabled attribute'
do
put
(
api
(
"/projects/
#{
project
.
id
}
"
,
user
),
packages_enabled:
false
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
project
.
reload
.
packages_enabled
).
to
be
false
expect
(
json_response
[
'packages_enabled'
]).
to
be_nil
end
end
end
end
describe
'GET /projects'
do
...
...
@@ -317,6 +351,24 @@ describe API::Projects do
expect
(
json_response
[
'external_authorization_classification_label'
]).
to
be_nil
end
end
describe
'packages_enabled attribute'
do
it
'exposed when the feature is available'
do
stub_licensed_features
(
packages:
true
)
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
expect
(
json_response
).
to
have_key
'packages_enabled'
end
it
'not exposed when the feature is available'
do
stub_licensed_features
(
packages:
false
)
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
expect
(
json_response
).
not_to
have_key
'packages_enabled'
end
end
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