Commit 9a4b5f08 authored by Rémy Coutable's avatar Rémy Coutable

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
parents d1154dcd d48ee860
...@@ -182,7 +182,7 @@ class ProjectsController < Projects::ApplicationController ...@@ -182,7 +182,7 @@ class ProjectsController < Projects::ApplicationController
end end
def housekeeping def housekeeping
::Projects::HousekeepingService.new(@project).execute ::Projects::HousekeepingService.new(@project, :gc).execute
redirect_to( redirect_to(
project_path(@project), project_path(@project),
......
---
title: Make Housekeeping button do a full garbage collection
merge_request: 30289
author:
type: fixed
...@@ -474,7 +474,7 @@ module API ...@@ -474,7 +474,7 @@ module API
authorize_admin_project authorize_admin_project
begin begin
::Projects::HousekeepingService.new(user_project).execute ::Projects::HousekeepingService.new(user_project, :gc).execute
rescue ::Projects::HousekeepingService::LeaseTaken => error rescue ::Projects::HousekeepingService::LeaseTaken => error
conflict!(error.message) conflict!(error.message)
end end
......
...@@ -318,6 +318,53 @@ describe ProjectsController do ...@@ -318,6 +318,53 @@ describe ProjectsController do
end end
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 describe "#update" do
render_views render_views
......
...@@ -2428,7 +2428,7 @@ describe API::Projects do ...@@ -2428,7 +2428,7 @@ describe API::Projects do
let(:housekeeping) { Projects::HousekeepingService.new(project) } let(:housekeeping) { Projects::HousekeepingService.new(project) }
before do 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 end
context 'when authenticated as owner' do context 'when authenticated as owner' 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