Commit ba1a453ef3dddf50a2c118f4490267b19a0b2cc8
Exists in
master
and in
4 other branches
Merge pull request #3053 from m4tthumphrey/api-delete-hook-by-id
Fix RESTfulness of project hook deletions by API
Showing
3 changed files
with
6 additions
and
8 deletions
Show diff stats
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
@@ -261,7 +261,7 @@ describe Gitlab::API do | @@ -261,7 +261,7 @@ describe Gitlab::API do | ||
261 | it "should add hook to project" do | 261 | it "should add hook to project" do |
262 | expect { | 262 | expect { |
263 | post api("/projects/#{project.id}/hooks", user), | 263 | post api("/projects/#{project.id}/hooks", user), |
264 | - "url" => "http://example.com" | 264 | + url: "http://example.com" |
265 | }.to change {project.hooks.count}.by(1) | 265 | }.to change {project.hooks.count}.by(1) |
266 | end | 266 | end |
267 | end | 267 | end |
@@ -275,12 +275,10 @@ describe Gitlab::API do | @@ -275,12 +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), | ||
283 | - hook_id: hook.id | 281 | + delete api("/projects/#{project.id}/hooks/#{hook.id}", user) |
284 | }.to change {project.hooks.count}.by(-1) | 282 | }.to change {project.hooks.count}.by(-1) |
285 | end | 283 | end |
286 | end | 284 | end |