Commit 0f71b4bc authored by Douwe Maan's avatar Douwe Maan

Merge branch 'zj-nillify-pool-repo-when-leaving' into 'master'

Nullify pool_repository when a project leaves

See merge request gitlab-org/gitlab-ce!24225
parents e593e14a e672ed84
......@@ -85,7 +85,11 @@ class PoolRepository < ActiveRecord::Base
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 @@ class Project < ActiveRecord::Base
end
def leave_pool_repository
pool_repository&.unlink_repository(repository)
pool_repository&.unlink_repository(repository) && update_column(:pool_repository_id, nil)
end
private
......
......@@ -4443,6 +4443,17 @@ describe Project do
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