Merge Request uses StateMachine now
This commit is contained in:
parent
b45e9aefd3
commit
29f70acc98
|
@ -25,7 +25,7 @@ class MergeRequest < ActiveRecord::Base
|
||||||
include Issuable
|
include Issuable
|
||||||
|
|
||||||
attr_accessible :title, :assignee_id, :target_branch, :source_branch, :milestone_id,
|
attr_accessible :title, :assignee_id, :target_branch, :source_branch, :milestone_id,
|
||||||
:author_id_of_changes
|
:author_id_of_changes, :state_event
|
||||||
|
|
||||||
attr_accessor :should_remove_source_branch
|
attr_accessor :should_remove_source_branch
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
class MergeRequest < Grape::Entity
|
class MergeRequest < Grape::Entity
|
||||||
expose :id, :target_branch, :source_branch, :project_id, :title, :closed, :merged
|
expose :id, :target_branch, :source_branch, :project_id, :title, :state
|
||||||
expose :author, :assignee, using: Entities::UserBasic
|
expose :author, :assignee, using: Entities::UserBasic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -73,12 +73,12 @@ module Gitlab
|
||||||
# target_branch - The target branch
|
# target_branch - The target branch
|
||||||
# assignee_id - Assignee user ID
|
# assignee_id - Assignee user ID
|
||||||
# title - Title of MR
|
# title - Title of MR
|
||||||
# closed - Status of MR. true - closed
|
# state_event - Status of MR. (close|reopen|merge)
|
||||||
# Example:
|
# Example:
|
||||||
# PUT /projects/:id/merge_request/:merge_request_id
|
# PUT /projects/:id/merge_request/:merge_request_id
|
||||||
#
|
#
|
||||||
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, :state_event]
|
||||||
merge_request = user_project.merge_requests.find(params[:merge_request_id])
|
merge_request = user_project.merge_requests.find(params[:merge_request_id])
|
||||||
|
|
||||||
authorize! :modify_merge_request, merge_request
|
authorize! :modify_merge_request, merge_request
|
||||||
|
|
|
@ -43,6 +43,23 @@ describe Gitlab::API do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "PUT /projects/:id/merge_request/:merge_request_id to close MR" do
|
||||||
|
it "should return merge_request" do
|
||||||
|
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "close"
|
||||||
|
response.status.should == 200
|
||||||
|
json_response['state'].should == 'closed'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "PUT /projects/:id/merge_request/:merge_request_id to merge MR" do
|
||||||
|
it "should return merge_request" do
|
||||||
|
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "merge"
|
||||||
|
response.status.should == 200
|
||||||
|
json_response['state'].should == 'merged'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
describe "PUT /projects/:id/merge_request/:merge_request_id" do
|
describe "PUT /projects/:id/merge_request/:merge_request_id" do
|
||||||
it "should return merge_request" do
|
it "should return merge_request" do
|
||||||
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), title: "New title"
|
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), title: "New title"
|
||||||
|
|
Loading…
Reference in a new issue