diff options
author | Stan Hu <stanhu@gmail.com> | 2019-07-03 00:13:00 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-07-03 00:21:33 -0700 |
commit | d48ee86053acabf4d52effc2a6a2ba714926821d (patch) | |
tree | 9099583adb0e1c8fd2858a0f91122608a0f223a2 /spec/controllers/projects_controller_spec.rb | |
parent | 38d46edba584b59b7307ed219f5e5ad9dd0b6de6 (diff) | |
download | gitlab-ce-d48ee86053acabf4d52effc2a6a2ba714926821d.tar.gz |
Make Housekeeping button do a full garbage collectionsh-fix-issue-63349
Previously the Housekeeping button and API would use the counter of last
pushes to determine whether to do a full garbage collection, or whether
to do one of the less comprehensive tasks: a full repack, incremental
pack, or ref pack. This was confusing behavior, since a project owner
might have to click the button dozens of times before a full GC would be
initiated.
This commit forces a full GC each time this is initiated. Note that the
`ExclusiveLease` in `HousekeepingService` prevents users from clicking
on the button more than once a day.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63349
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 8d2412f97ef..4e1cac67d23 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -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 |