summaryrefslogtreecommitdiff
path: root/lib/api/merge_requests.rb
diff options
context:
space:
mode:
authorValeriy Sizov <vsv2711@gmail.com>2012-10-21 15:33:02 +0300
committerValeriy Sizov <vsv2711@gmail.com>2012-10-22 23:09:21 +0300
commit524b907042c36d832b82d980c9fee85e6d92b6da (patch)
treee39c728c2ee55a15a74db47d459a9959ed84b508 /lib/api/merge_requests.rb
parent5a89934af8bd09d40c01c940b2305f95374be1bd (diff)
downloadgitlab-ce-524b907042c36d832b82d980c9fee85e6d92b6da.tar.gz
API: MergeRequest refactoring
Diffstat (limited to 'lib/api/merge_requests.rb')
-rw-r--r--lib/api/merge_requests.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 92ff4937577..f1d8d6a9b55 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -6,21 +6,18 @@ module Gitlab
resource :projects do
#list
get ":id/merge_requests" do
- project = current_user.projects.find(params[:id])
- present project.merge_requests, with: Entities::MergeRequest
+ present user_project.merge_requests, with: Entities::MergeRequest
end
#show
get ":id/merge_request/:merge_request_id" do
- project = current_user.projects.find(params[:id])
- present project.merge_requests.find(params[:merge_request_id]), with: Entities::MergeRequest
+ present user_project.merge_requests.find(params[:merge_request_id]), with: Entities::MergeRequest
end
#create merge_request
post ":id/merge_requests" do
attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title]
- project = current_user.projects.find(params[:id])
- merge_request = project.merge_requests.new(attrs)
+ merge_request = user_project.merge_requests.new(attrs)
merge_request.author = current_user
if merge_request.save
@@ -34,8 +31,7 @@ module Gitlab
#update merge_request
put ":id/merge_request/:merge_request_id" do
attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :closed]
- project = current_user.projects.find(params[:id])
- merge_request = project.merge_requests.find(params[:merge_request_id])
+ merge_request = user_project.merge_requests.find(params[:merge_request_id])
if merge_request.update_attributes attrs
merge_request.reload_code