Commit 25e4bfae authored by manojmj's avatar manojmj

Expose 'marked_for_deletion_on' attribute in Projects API

This change exposes the 'marked_for_deletion_on'
attribute in Projects API response
parent 85cf0320
...@@ -162,6 +162,8 @@ When the user is authenticated and `simple` is not set this returns something li ...@@ -162,6 +162,8 @@ When the user is authenticated and `simple` is not set this returns something li
"merge_method": "merge", "merge_method": "merge",
"autoclose_referenced_issues": true, "autoclose_referenced_issues": true,
"suggestion_commit_message": null, "suggestion_commit_message": null,
"marked_for_deletion_at": "2020-04-03",
"marked_for_deletion_on": "2020-04-03",
"statistics": { "statistics": {
"commit_count": 37, "commit_count": 37,
"storage_size": 1038090, "storage_size": 1038090,
...@@ -406,6 +408,8 @@ This endpoint supports [keyset pagination](README.md#keyset-based-pagination) fo ...@@ -406,6 +408,8 @@ This endpoint supports [keyset pagination](README.md#keyset-based-pagination) fo
"merge_method": "merge", "merge_method": "merge",
"autoclose_referenced_issues": true, "autoclose_referenced_issues": true,
"suggestion_commit_message": null, "suggestion_commit_message": null,
"marked_for_deletion_at": "2020-04-03",
"marked_for_deletion_on": "2020-04-03",
"statistics": { "statistics": {
"commit_count": 37, "commit_count": 37,
"storage_size": 1038090, "storage_size": 1038090,
...@@ -870,6 +874,8 @@ GET /projects/:id ...@@ -870,6 +874,8 @@ GET /projects/:id
"service_desk_address": null, "service_desk_address": null,
"autoclose_referenced_issues": true, "autoclose_referenced_issues": true,
"suggestion_commit_message": null, "suggestion_commit_message": null,
"marked_for_deletion_at": "2020-04-03",
"marked_for_deletion_on": "2020-04-03",
"statistics": { "statistics": {
"commit_count": 37, "commit_count": 37,
"storage_size": 1038090, "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 ...@@ -19,6 +19,9 @@ module EE
expose :service_desk_enabled, if: ->(project, _) { project.feature_available?(:service_desk) } expose :service_desk_enabled, if: ->(project, _) { project.feature_available?(:service_desk) }
expose :service_desk_address, 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_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 end
end end
......
...@@ -180,21 +180,49 @@ describe API::Projects do ...@@ -180,21 +180,49 @@ describe API::Projects do
end end
end end
describe 'marked_for_deletion attribute' do context 'project soft-deletion' do
it 'exposed when the feature is available' do subject { get api("/projects/#{project.id}", user) }
stub_licensed_features(adjourned_deletion_for_projects_and_groups: true)
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 end
it 'not exposed when the feature is not available' do describe 'marked_for_deletion_on attribute' do
stub_licensed_features(adjourned_deletion_for_projects_and_groups: false) 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 end
end end
...@@ -621,6 +649,7 @@ describe API::Projects do ...@@ -621,6 +649,7 @@ describe API::Projects do
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(json_response['archived']).to be_falsey expect(json_response['archived']).to be_falsey
expect(json_response['marked_for_deletion_at']).to be_falsey expect(json_response['marked_for_deletion_at']).to be_falsey
expect(json_response['marked_for_deletion_on']).to be_falsey
end end
it 'returns error if project is already being deleted' do 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