Commit 0e82c981 authored by Izaak Alpert's avatar Izaak Alpert

Fix merge_requests_controller

-update new to be simplified (set values from parms via rails) instead of doing it by hand
-change def merge_request to look up the merge request against the current @project

Change-Id: I778c91b87c6da84b73f8f59013c27b74d290d8b1
parent fae3f466
...@@ -39,16 +39,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -39,16 +39,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def new def new
@merge_request = @project.merge_requests.new(params[:merge_request]) @merge_request = MergeRequest.new(params[:merge_request])
@merge_request.source_project = @project unless @merge_request.source_project
if params[:merge_request] && params[:merge_request][:source_project_id] @merge_request.target_project = @project unless @merge_request.target_project
@merge_request.source_project = Project.find_by_id(params[:merge_request][:source_project_id])
else
@merge_request.source_project = @project
end
if params[:merge_request] && params[:merge_request][:target_project_id]
@merge_request.target_project = Project.find_by_id(params[:merge_request][:target_project_id])
end
@target_branches = @merge_request.target_project.nil? ? [] : @merge_request.target_project.repository.branch_names @target_branches = @merge_request.target_project.nil? ? [] : @merge_request.target_project.repository.branch_names
@source_project = @merge_request.source_project @source_project = @merge_request.source_project
@merge_request @merge_request
...@@ -138,7 +131,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -138,7 +131,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def merge_request def merge_request
@merge_request ||= MergeRequest.find_by_id(params[:id]) @merge_request ||= @project.merge_requests.find(params[:id])
end end
def authorize_modify_merge_request! def authorize_modify_merge_request!
......
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