Commit 524b9070 authored by Valeriy Sizov's avatar Valeriy Sizov

API: MergeRequest refactoring

parent 5a89934a
...@@ -6,21 +6,18 @@ module Gitlab ...@@ -6,21 +6,18 @@ module Gitlab
resource :projects do resource :projects do
#list #list
get ":id/merge_requests" do get ":id/merge_requests" do
project = current_user.projects.find(params[:id]) present user_project.merge_requests, with: Entities::MergeRequest
present project.merge_requests, with: Entities::MergeRequest
end end
#show #show
get ":id/merge_request/:merge_request_id" do get ":id/merge_request/:merge_request_id" do
project = current_user.projects.find(params[:id]) present user_project.merge_requests.find(params[:merge_request_id]), with: Entities::MergeRequest
present project.merge_requests.find(params[:merge_request_id]), with: Entities::MergeRequest
end end
#create merge_request #create merge_request
post ":id/merge_requests" do post ":id/merge_requests" do
attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title] attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title]
project = current_user.projects.find(params[:id]) merge_request = user_project.merge_requests.new(attrs)
merge_request = project.merge_requests.new(attrs)
merge_request.author = current_user merge_request.author = current_user
if merge_request.save if merge_request.save
...@@ -34,8 +31,7 @@ module Gitlab ...@@ -34,8 +31,7 @@ module Gitlab
#update merge_request #update merge_request
put ":id/merge_request/:merge_request_id" do put ":id/merge_request/:merge_request_id" do
attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :closed] attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :closed]
project = current_user.projects.find(params[:id]) merge_request = user_project.merge_requests.find(params[:merge_request_id])
merge_request = project.merge_requests.find(params[:merge_request_id])
if merge_request.update_attributes attrs if merge_request.update_attributes attrs
merge_request.reload_code merge_request.reload_code
......
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