Store the name of a project that's a root of a fork network

So we can keep showing it to a user in his project page.
This commit is contained in:
Bob Van Landuyt 2017-10-03 18:27:51 +02:00
parent f90b27da77
commit 14a6cebc9f
2 changed files with 20 additions and 0 deletions

View file

@ -22,6 +22,13 @@ module Projects
Projects::UnlinkForkService.new(project, current_user).execute
# The project is not necessarily a fork, so update the fork network originating
# from this project
if fork_network = project.root_of_fork_network
fork_network.update(root_project: nil,
deleted_root_project_name: project.full_name)
end
attempt_destroy_transaction(project)
system_hook_service.execute_hooks_for(project, :destroy)

View file

@ -212,6 +212,19 @@ describe Projects::DestroyService do
end
end
context 'as the root of a fork network' do
let!(:fork_network) { create(:fork_network, root_project: project) }
it 'updates the fork network with the project name' do
destroy_project(project, user)
fork_network.reload
expect(fork_network.deleted_root_project_name).to eq(project.full_name)
expect(fork_network.root_project).to be_nil
end
end
def destroy_project(project, user, params = {})
if async
Projects::DestroyService.new(project, user, params).async_execute