Commit 8c77a1fb authored by Katarzyna Kobierska's avatar Katarzyna Kobierska

Before deleting project if forked unlink fork

parent a0c46221
......@@ -27,6 +27,8 @@ module Projects
# Git data (e.g. a list of branch names).
flush_caches(project, wiki_path)
Projects::UnlinkForkService.new(project, current_user).execute
Project.transaction do
project.destroy!
......
......@@ -181,6 +181,23 @@ describe ProjectsController do
expect(response).to have_http_status(302)
expect(response).to redirect_to(dashboard_projects_path)
end
context "when project is forked" do
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
let(:merge_request) do
create(:merge_request,
source_project: fork_project,
target_project: project)
end
it "closes all related merge requests" do
fork_project.destroy
expect(fork_project.destroyed?).to be_truthy
expect(merge_request.state).to eq('closed')
end
end
end
describe "POST #toggle_star" do
......
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