Commit 25edb070 authored by Katarzyna Kobierska's avatar Katarzyna Kobierska

Close merge request if open without source project

parent dde96231
...@@ -417,8 +417,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -417,8 +417,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def validates_merge_request def validates_merge_request
# If source project was removed and merge request for some reason # If source project was removed and merge request for some reason
# wasn't close (Ex. mr from fork to origin) # wasn't close (Ex. mr from fork to origin) merge request will be closed
return invalid_mr if !@merge_request.source_project && @merge_request.open? if !@merge_request.source_project && @merge_request.open?
@merge_request.close
end
# 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
......
...@@ -41,4 +41,17 @@ describe 'projects/merge_requests/show.html.haml' do ...@@ -41,4 +41,17 @@ describe 'projects/merge_requests/show.html.haml' do
expect(rendered).to have_css('a', visible: false, text: 'Close') expect(rendered).to have_css('a', visible: false, text: 'Close')
end end
end end
context 'when the merge request is open' do
it 'closes open merge request' do
closed_merge_request.update_attributes(state: 'open')
fork_project.destroy
render
expect(closed_merge_request.reload.state).to eq('closed')
expect(rendered).to have_css('a', visible: false, text: 'Reopen')
expect(rendered).to have_css('a', visible: false, text: 'Close')
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