Commit 1f2de8dd authored by Thong Kuah's avatar Thong Kuah

Merge branch...

Merge branch '212937-marked_for_deletion_on-not-consistent-with-marked_for_deletion_at-in-codebase-and-api' into 'master'

Expose 'marked_for_deletion_on' attribute in Projects API

See merge request gitlab-org/gitlab!28754
parents b0f5b3ff 25e4bfae
......@@ -162,6 +162,8 @@ When the user is authenticated and `simple` is not set this returns something li
"merge_method": "merge",
"autoclose_referenced_issues": true,
"suggestion_commit_message": null,
"marked_for_deletion_at": "2020-04-03",
"marked_for_deletion_on": "2020-04-03",
"statistics": {
"commit_count": 37,
"storage_size": 1038090,
......@@ -406,6 +408,8 @@ This endpoint supports [keyset pagination](README.md#keyset-based-pagination) fo
"merge_method": "merge",
"autoclose_referenced_issues": true,
"suggestion_commit_message": null,
"marked_for_deletion_at": "2020-04-03",
"marked_for_deletion_on": "2020-04-03",
"statistics": {
"commit_count": 37,
"storage_size": 1038090,
......@@ -870,6 +874,8 @@ GET /projects/:id
"service_desk_address": null,
"autoclose_referenced_issues": true,
"suggestion_commit_message": null,
"marked_for_deletion_at": "2020-04-03",
"marked_for_deletion_on": "2020-04-03",
"statistics": {
"commit_count": 37,
"storage_size": 1038090,
......
---
title: Expose 'marked_for_deletion_on' attribute in Projects API
merge_request: 28754
author:
type: added
......@@ -19,6 +19,9 @@ module EE
expose :service_desk_enabled, if: ->(project, _) { project.feature_available?(:service_desk) }
expose :service_desk_address, if: ->(project, _) { project.feature_available?(:service_desk) }
expose :marked_for_deletion_at, if: ->(project, _) { project.feature_available?(:adjourned_deletion_for_projects_and_groups) }
expose :marked_for_deletion_on, if: ->(project, _) { project.feature_available?(:adjourned_deletion_for_projects_and_groups) } do |project, _|
project.marked_for_deletion_at
end
end
end
end
......
......@@ -180,21 +180,49 @@ describe API::Projects do
end
end
describe 'marked_for_deletion attribute' do
it 'exposed when the feature is available' do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true)
context 'project soft-deletion' do
subject { get api("/projects/#{project.id}", user) }
get api("/projects/#{project.id}", user)
let(:project) do
create(:project, :public, archived: true, marked_for_deletion_at: 1.day.ago, deleting_user: user)
end
describe 'marked_for_deletion_at attribute' do
it 'exposed when the feature is available' do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true)
subject
expect(json_response).to have_key 'marked_for_deletion_at'
expect(Date.parse(json_response['marked_for_deletion_at'])).to eq(project.marked_for_deletion_at)
end
it 'not exposed when the feature is not available' do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: false)
expect(json_response).to have_key 'marked_for_deletion_at'
subject
expect(json_response).not_to have_key 'marked_for_deletion_at'
end
end
it 'not exposed when the feature is not available' do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: false)
describe 'marked_for_deletion_on attribute' do
it 'exposed when the feature is available' do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true)
get api("/projects/#{project.id}", user)
subject
expect(json_response).not_to have_key 'marked_for_deletion_at'
expect(json_response).to have_key 'marked_for_deletion_on'
expect(Date.parse(json_response['marked_for_deletion_on'])).to eq(project.marked_for_deletion_at)
end
it 'not exposed when the feature is not available' do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: false)
subject
expect(json_response).not_to have_key 'marked_for_deletion_on'
end
end
end
end
......@@ -621,6 +649,7 @@ describe API::Projects do
expect(response).to have_gitlab_http_status(:created)
expect(json_response['archived']).to be_falsey
expect(json_response['marked_for_deletion_at']).to be_falsey
expect(json_response['marked_for_deletion_on']).to be_falsey
end
it 'returns error if project is already being deleted' 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