Merge branch 'sh-fix-issue-63349' into 'master'

Make Housekeeping button do a full garbage collection

Closes #63349

See merge request gitlab-org/gitlab-ce!30289
This commit is contained in:
Rémy Coutable 2019-07-04 07:38:56 +00:00
commit 9a4b5f08db
5 changed files with 55 additions and 3 deletions

View File

@ -182,7 +182,7 @@ class ProjectsController < Projects::ApplicationController
end
def housekeeping
::Projects::HousekeepingService.new(@project).execute
::Projects::HousekeepingService.new(@project, :gc).execute
redirect_to(
project_path(@project),

View File

@ -0,0 +1,5 @@
---
title: Make Housekeeping button do a full garbage collection
merge_request: 30289
author:
type: fixed

View File

@ -474,7 +474,7 @@ module API
authorize_admin_project
begin
::Projects::HousekeepingService.new(user_project).execute
::Projects::HousekeepingService.new(user_project, :gc).execute
rescue ::Projects::HousekeepingService::LeaseTaken => error
conflict!(error.message)
end

View File

@ -318,6 +318,53 @@ describe ProjectsController do
end
end
describe '#housekeeping' do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:housekeeping) { Projects::HousekeepingService.new(project) }
context 'when authenticated as owner' do
before do
group.add_owner(user)
sign_in(user)
allow(Projects::HousekeepingService).to receive(:new).with(project, :gc).and_return(housekeeping)
end
it 'forces a full garbage collection' do
expect(housekeeping).to receive(:execute).once
post :housekeeping,
params: {
namespace_id: project.namespace.path,
id: project.path
}
expect(response).to have_gitlab_http_status(302)
end
end
context 'when authenticated as developer' do
let(:developer) { create(:user) }
before do
group.add_developer(developer)
end
it 'does not execute housekeeping' do
expect(housekeeping).not_to receive(:execute)
post :housekeeping,
params: {
namespace_id: project.namespace.path,
id: project.path
}
expect(response).to have_gitlab_http_status(302)
end
end
end
describe "#update" do
render_views

View File

@ -2428,7 +2428,7 @@ describe API::Projects do
let(:housekeeping) { Projects::HousekeepingService.new(project) }
before do
allow(Projects::HousekeepingService).to receive(:new).with(project).and_return(housekeeping)
allow(Projects::HousekeepingService).to receive(:new).with(project, :gc).and_return(housekeeping)
end
context 'when authenticated as owner' do