Unverified Commit e672ed84 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg
Browse files

Nullify pool_repository when a project leaves

Previously the nullification wasn't done, as the only caller would later
destroy the model all together. In
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9070 this change
was made. This commit is basically a backport before that MR is merged.
parent a996e4e3
......@@ -85,7 +85,11 @@ def link_repository(repository)
def unlink_repository(repository)
object_pool.unlink_repository(repository.raw)
mark_obsolete unless member_projects.where.not(id: repository.project.id).exists?
if member_projects.where.not(id: repository.project.id).exists?
true
else
mark_obsolete
end
end
def object_pool
......
......@@ -2040,7 +2040,7 @@ def git_objects_poolable?
end
def leave_pool_repository
pool_repository&.unlink_repository(repository)
pool_repository&.unlink_repository(repository) && update_column(:pool_repository_id, nil)
end
private
......
......@@ -4387,6 +4387,17 @@ def domain_variable
end
end
describe '#leave_pool_repository' do
let(:pool) { create(:pool_repository) }
let(:project) { create(:project, :repository, pool_repository: pool) }
it 'removes the membership' do
project.leave_pool_repository
expect(pool.member_projects.reload).not_to include(project)
end
end
def rugged_config
rugged_repo(project.repository).config
end
......
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