Commit 33c513274d2201787d592850e60a018b777e0c43

Authored by Matt Humphrey
1 parent b7ac654b

Fix RESTfulness of project hook deletions by API

doc/api/projects.md
@@ -265,7 +265,7 @@ Will return status `201 Created` on success, or `404 Not found` on fail. @@ -265,7 +265,7 @@ Will return status `201 Created` on success, or `404 Not found` on fail.
265 Delete hook from project 265 Delete hook from project
266 266
267 ``` 267 ```
268 -DELETE /projects/:id/hooks 268 +DELETE /projects/:id/hooks/:hook_id
269 ``` 269 ```
270 270
271 Parameters: 271 Parameters:
lib/api/projects.rb
@@ -205,8 +205,8 @@ module Gitlab @@ -205,8 +205,8 @@ module Gitlab
205 # id (required) - The ID of a project 205 # id (required) - The ID of a project
206 # hook_id (required) - The ID of hook to delete 206 # hook_id (required) - The ID of hook to delete
207 # Example Request: 207 # Example Request:
208 - # DELETE /projects/:id/hooks  
209 - delete ":id/hooks" do 208 + # DELETE /projects/:id/hooks/:hook_id
  209 + delete ":id/hooks/:hook_id" do
210 authorize! :admin_project, user_project 210 authorize! :admin_project, user_project
211 @hook = user_project.hooks.find(params[:hook_id]) 211 @hook = user_project.hooks.find(params[:hook_id])
212 @hook.destroy 212 @hook.destroy
spec/requests/api/projects_spec.rb
@@ -275,11 +275,10 @@ describe Gitlab::API do @@ -275,11 +275,10 @@ describe Gitlab::API do
275 end 275 end
276 end 276 end
277 277
278 -  
279 - describe "DELETE /projects/:id/hooks" do 278 + describe "DELETE /projects/:id/hooks/:hook_id" do
280 it "should delete hook from project" do 279 it "should delete hook from project" do
281 expect { 280 expect {
282 - delete api("/projects/#{project.id}/hooks", user), 281 + delete api("/projects/#{project.id}/hooks/#{hook.id}", user),
283 hook_id: hook.id 282 hook_id: hook.id
284 }.to change {project.hooks.count}.by(-1) 283 }.to change {project.hooks.count}.by(-1)
285 end 284 end