Commit 4775fb9e authored by Ash McKenzie's avatar Ash McKenzie

Render 'invalid' if #target_branch_missing?

parent d87552a8
......@@ -28,15 +28,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
end
def show
validates_merge_request
# Return if the response has already been rendered
return if response_body
close_merge_request_if_no_source_project
mark_merge_request_mergeable
respond_to do |format|
format.html do
# use next to appease Rubocop
next render('invalid') if target_branch_missing?
# Build a note object for comment form
@note = @project.notes.new(noteable: @merge_request)
......@@ -234,20 +233,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
alias_method :issuable, :merge_request
alias_method :awardable, :merge_request
def validates_merge_request
# Show git not found page
# if there is no saved commits between source & target branch
if @merge_request.has_no_commits?
# and if target branch doesn't exist
return invalid_mr unless @merge_request.target_branch_exists?
end
end
def invalid_mr
# Render special view for MR with removed target branch
render 'invalid'
end
def merge_params
params.permit(merge_params_attributes)
end
......@@ -269,6 +254,10 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
private
def target_branch_missing?
@merge_request.has_no_commits? && !@merge_request.target_branch_exists?
end
def mark_merge_request_mergeable
@merge_request.check_if_can_be_merged
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