diff options
author | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-09-01 14:42:17 +0300 |
---|---|---|
committer | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-09-13 15:40:05 +0300 |
commit | 8c77a1fb250cf6d6ca06bedc3b52fc62f1cc4819 (patch) | |
tree | 35a5860360398b88b403d532ae7c262c0ad633fa | |
parent | a0c46221626ae367c3da68e38a6d5dde7dda32db (diff) |
Before deleting project if forked unlink fork
-rw-r--r-- | app/services/projects/destroy_service.rb | 2 | ||||
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index 8a53f65aec1..a08c6fcd94b 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -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! diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index ffe0641ddd7..95315d86c4d 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -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 |