diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 28f1acf5fc4b63d5054a6d005123085454cecf48..b452bfd7e6f414fe5a631b7520be49c6e5c21e7f 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -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