Commit 59ceea8e authored by Robert Speicher's avatar Robert Speicher

Merge branch 'mo-add-attribute-to-project-rest-api' into 'master'

Add keep_latest_artifact to project REST API

See merge request gitlab-org/gitlab!63785
parents 13b240cb 76aabea7
......@@ -1378,6 +1378,7 @@ PUT /projects/:id
| `wiki_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable wiki for this project. Use `wiki_access_level` instead. |
| `issues_template` **(PREMIUM)** | string | **{dotted-circle}** No | Default description for Issues. Description is parsed with GitLab Flavored Markdown. See [Templates for issues and merge requests](#templates-for-issues-and-merge-requests). |
| `merge_requests_template` **(PREMIUM)** | string | **{dotted-circle}** No | Default description for Merge Requests. Description is parsed with GitLab Flavored Markdown. See [Templates for issues and merge requests](#templates-for-issues-and-merge-requests). |
| `keep_latest_artifact` | boolean | **{dotted-circle}** No | Disable or enable the ability to keep the latest artifact for this project. |
## Fork project
......
......@@ -128,6 +128,7 @@ module API
expose :repository_storage, if: ->(project, options) {
Ability.allowed?(options[:current_user], :change_repository_storage, project)
}
expose :keep_latest_artifacts_available?, as: :keep_latest_artifact
# rubocop: disable CodeReuse/ActiveRecord
def self.preload_relation(projects_relation, options = {})
......
......@@ -16,6 +16,7 @@ module API
optional :build_coverage_regex, type: String, desc: 'Test coverage parsing'
optional :ci_config_path, type: String, desc: 'The path to CI config file. Defaults to `.gitlab-ci.yml`'
optional :service_desk_enabled, type: Boolean, desc: 'Disable or enable the service desk'
optional :keep_latest_artifact, type: Boolean, desc: 'Indicates if the latest artifact should be kept for this project.'
# TODO: remove in API v5, replaced by *_access_level
optional :issues_enabled, type: Boolean, desc: 'Flag indication if the issue tracker is enabled'
......@@ -156,6 +157,7 @@ module API
:compliance_framework_setting,
:packages_enabled,
:service_desk_enabled,
:keep_latest_artifact,
# TODO: remove in API v5, replaced by *_access_level
:issues_enabled,
......
......@@ -87,7 +87,6 @@ ci_cd_settings:
- id
- project_id
- group_runners_enabled
- keep_latest_artifact
- merge_pipelines_enabled
- merge_trains_enabled
- auto_rollback_enabled
......
......@@ -2110,6 +2110,7 @@ RSpec.describe API::Projects do
expect(json_response['squash_option']).to eq(project.squash_option.to_s)
expect(json_response['readme_url']).to eq(project.readme_url)
expect(json_response).to have_key 'packages_enabled'
expect(json_response['keep_latest_artifact']).to be_present
end
it 'returns a group link with expiration date' do
......@@ -3300,6 +3301,24 @@ RSpec.describe API::Projects do
expect { subject }.to change { project.reload.service_desk_enabled }.to(true)
end
end
context 'when updating keep latest artifact' do
subject { put(api("/projects/#{project.id}", user), params: { keep_latest_artifact: true }) }
before do
project.update!(keep_latest_artifact: false)
end
it 'returns 200' do
subject
expect(response).to have_gitlab_http_status(:ok)
end
it 'enables keep_latest_artifact' do
expect { subject }.to change { project.reload.keep_latest_artifact }.to(true)
end
end
end
describe 'POST /projects/:id/archive' 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