summaryrefslogtreecommitdiff
path: root/spec/models/pool_repository_spec.rb
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-12-17 09:49:38 +0100
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-12-19 13:21:56 +0100
commit752e9c18a1c2521636ddeec65b7bda2035ce1893 (patch)
tree157a76334e9c54264dde1dda62eb85f1b17e5914 /spec/models/pool_repository_spec.rb
parent73d4b1f625af4cb9e10c4e862ed63a54904f746f (diff)
downloadgitlab-ce-752e9c18a1c2521636ddeec65b7bda2035ce1893.tar.gz
Leave object pools when destroying projects
This action doesn't lean on reduplication, so a short call can me made to the Gitaly server to have the object pool remove its remote to the project pending deletion. https://gitlab.com/gitlab-org/gitaly/blob/f6cd55357/internal/git/objectpool/link.go#L58 When an object pool doesn't have members, this would invalidate the need for a pool. So when a project leaves the pool, the pool will be destroyed on the background. Fixes: https://gitlab.com/gitlab-org/gitaly/issues/1415
Diffstat (limited to 'spec/models/pool_repository_spec.rb')
-rw-r--r--spec/models/pool_repository_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/pool_repository_spec.rb b/spec/models/pool_repository_spec.rb
index 3d3878b8c39..112d4ab56fc 100644
--- a/spec/models/pool_repository_spec.rb
+++ b/spec/models/pool_repository_spec.rb
@@ -23,4 +23,25 @@ describe PoolRepository do
expect(pool.disk_path).to match(%r{\A@pools/\h{2}/\h{2}/\h{64}})
end
end
+
+ describe '#unlink_repository' do
+ let(:pool) { create(:pool_repository, :ready) }
+
+ context 'when the last member leaves' do
+ it 'schedules pool removal' do
+ expect(::ObjectPool::DestroyWorker).to receive(:perform_async).with(pool.id).and_call_original
+
+ pool.unlink_repository(pool.source_project.repository)
+ end
+ end
+
+ context 'when the second member leaves' do
+ it 'does not schedule pool removal' do
+ create(:project, :repository, pool_repository: pool)
+ expect(::ObjectPool::DestroyWorker).not_to receive(:perform_async).with(pool.id)
+
+ pool.unlink_repository(pool.source_project.repository)
+ end
+ end
+ end
end