Commit 09cded29 authored by Katarzyna Kobierska's avatar Katarzyna Kobierska

Checks if deleting forked project closed all open merge requests

parent 8c77a1fb
...@@ -429,7 +429,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -429,7 +429,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def validates_merge_request def validates_merge_request
# If source project was removed (Ex. mr from fork to origin) # If source project was removed (Ex. mr from fork to origin)
return invalid_mr unless @merge_request.source_project # return invalid_mr unless @merge_request.source_project
# Show git not found page # Show git not found page
# if there is no saved commits between source & target branch # if there is no saved commits between source & target branch
...@@ -438,7 +438,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -438,7 +438,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
return invalid_mr unless @merge_request.target_branch_exists? return invalid_mr unless @merge_request.target_branch_exists?
# or if source branch doesn't exist # or if source branch doesn't exist
return invalid_mr unless @merge_request.source_branch_exists? # return invalid_mr unless @merge_request.source_branch_exists?
end end
end end
......
...@@ -313,7 +313,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -313,7 +313,7 @@ class MergeRequest < ActiveRecord::Base
end end
def closed_without_fork? def closed_without_fork?
closed? && forked_source_project_missing? closed? && (forked_source_project_missing? || !source_project)
end end
def forked_source_project_missing? def forked_source_project_missing?
......
...@@ -192,10 +192,12 @@ describe ProjectsController do ...@@ -192,10 +192,12 @@ describe ProjectsController do
end end
it "closes all related merge requests" do it "closes all related merge requests" do
fork_project.destroy project.merge_requests << merge_request
sign_in(admin)
delete :destroy, namespace_id: fork_project.namespace.path, id: fork_project.path
expect(fork_project.destroyed?).to be_truthy expect(merge_request.reload.state).to eq('closed')
expect(merge_request.state).to eq('closed')
end end
end end
end 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