BigW Consortium Gitlab

Commit 21f4e5d3 by Dmitriy Zaporozhets

ProjectHook API supports new event fields

parent 822dac87
......@@ -402,6 +402,10 @@ Parameters:
{
"id": 1,
"url": "http://example.com/hook",
"project_id": 3,
"push_events": "true",
"issues_events": "true",
"merge_requests_events": "true",
"created_at": "2012-10-12T17:04:47Z"
}
```
......@@ -419,6 +423,9 @@ Parameters:
+ `id` (required) - The ID or NAME of a project
+ `url` (required) - The hook URL
+ `push_events` - Trigger hook on push events
+ `issues_events` - Trigger hook on issues events
+ `merge_requests_events` - Trigger hook on merge_requests events
### Edit project hook
......@@ -434,6 +441,9 @@ Parameters:
+ `id` (required) - The ID or NAME of a project
+ `hook_id` (required) - The ID of a project hook
+ `url` (required) - The hook URL
+ `push_events` - Trigger hook on push events
+ `issues_events` - Trigger hook on issues events
+ `merge_requests_events` - Trigger hook on merge_requests events
### Delete project hook
......
......@@ -47,8 +47,9 @@ module API
# POST /projects/:id/hooks
post ":id/hooks" do
required_attributes! [:url]
attrs = attributes_for_keys [:url, :push_events, :issues_events, :merge_requests_events]
@hook = user_project.hooks.new(attrs)
@hook = user_project.hooks.new({"url" => params[:url]})
if @hook.save
present @hook, with: Entities::ProjectHook
else
......@@ -70,8 +71,8 @@ module API
put ":id/hooks/:hook_id" do
@hook = user_project.hooks.find(params[:hook_id])
required_attributes! [:url]
attrs = attributes_for_keys [:url, :push_events, :issues_events, :merge_requests_events]
attrs = attributes_for_keys [:url]
if @hook.update_attributes attrs
present @hook, with: Entities::ProjectHook
else
......
......@@ -66,7 +66,7 @@ describe API::API, 'ProjectHooks' do
it "should add hook to project" do
expect {
post api("/projects/#{project.id}/hooks", user),
url: "http://example.com"
url: "http://example.com", issues_events: true
}.to change {project.hooks.count}.by(1)
response.status.should == 201
end
......@@ -85,7 +85,7 @@ describe API::API, 'ProjectHooks' do
describe "PUT /projects/:id/hooks/:hook_id" do
it "should update an existing project hook" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user),
url: 'http://example.org'
url: 'http://example.org', push_events: false
response.status.should == 200
json_response['url'].should == 'http://example.org'
end
......
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