Commit 85d8ab52 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'bvl-fix-deleting-forked-projects' into 'master'

Fix errors when deleting a forked project

Closes #39196

See merge request gitlab-org/gitlab-ce!14916
parents 2a1646b5 2c0b6776
......@@ -1272,7 +1272,7 @@ class Project < ActiveRecord::Base
# self.forked_from_project will be nil before the project is saved, so
# we need to go through the relation
original_project = forked_project_link.forked_from_project
original_project = forked_project_link&.forked_from_project
return true unless original_project
level <= original_project.visibility_level
......
......@@ -15,8 +15,8 @@ module Projects
refresh_forks_count(@project.forked_from_project)
@project.forked_project_link.destroy
@project.fork_network_member.destroy
@project.forked_project_link.destroy
end
def refresh_forks_count(project)
......
---
title: Fix error when updating a forked project with deleted `ForkedProjectLink`
merge_request: 14916
author:
type: fixed
require 'spec_helper'
describe Projects::DestroyService do
include ProjectForksHelper
let!(:user) { create(:user) }
let!(:project) { create(:project, :repository, namespace: user.namespace) }
let!(:path) { project.repository.path_to_repo }
......@@ -212,6 +214,21 @@ describe Projects::DestroyService do
end
end
context 'for a forked project with LFS objects' do
let(:forked_project) { fork_project(project, user) }
before do
project.lfs_objects << create(:lfs_object)
forked_project.forked_project_link.destroy
forked_project.reload
end
it 'destroys the fork' do
expect { destroy_project(forked_project, user) }
.not_to raise_error
end
end
context 'as the root of a fork network' do
let!(:fork_network) { create(:fork_network, root_project: project) }
......
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