From 33c513274d2201787d592850e60a018b777e0c43 Mon Sep 17 00:00:00 2001 From: Matt Humphrey Date: Wed, 20 Feb 2013 11:35:36 +0000 Subject: [PATCH 1/2] Fix RESTfulness of project hook deletions by API --- doc/api/projects.md | 2 +- lib/api/projects.rb | 4 ++-- spec/requests/api/projects_spec.rb | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/api/projects.md b/doc/api/projects.md index 13c53880..ed9690f0 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -265,7 +265,7 @@ Will return status `201 Created` on success, or `404 Not found` on fail. Delete hook from project ``` -DELETE /projects/:id/hooks +DELETE /projects/:id/hooks/:hook_id ``` Parameters: diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 921aa237..631ed535 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -205,8 +205,8 @@ module Gitlab # id (required) - The ID of a project # hook_id (required) - The ID of hook to delete # Example Request: - # DELETE /projects/:id/hooks - delete ":id/hooks" do + # DELETE /projects/:id/hooks/:hook_id + delete ":id/hooks/:hook_id" do authorize! :admin_project, user_project @hook = user_project.hooks.find(params[:hook_id]) @hook.destroy diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 586f108c..07f118fe 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -275,11 +275,10 @@ describe Gitlab::API do end end - - describe "DELETE /projects/:id/hooks" do + describe "DELETE /projects/:id/hooks/:hook_id" do it "should delete hook from project" do expect { - delete api("/projects/#{project.id}/hooks", user), + delete api("/projects/#{project.id}/hooks/#{hook.id}", user), hook_id: hook.id }.to change {project.hooks.count}.by(-1) end From dddf6eab2dc01dd2ac685f142a61824523fea50b Mon Sep 17 00:00:00 2001 From: Matt Humphrey Date: Wed, 20 Feb 2013 11:45:54 +0000 Subject: [PATCH 2/2] Removed unnecessary paramter hash. Also tidied up hash format in hook creation spec --- spec/requests/api/projects_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 07f118fe..d410885b 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -261,7 +261,7 @@ describe Gitlab::API do it "should add hook to project" do expect { post api("/projects/#{project.id}/hooks", user), - "url" => "http://example.com" + url: "http://example.com" }.to change {project.hooks.count}.by(1) end end @@ -278,8 +278,7 @@ describe Gitlab::API do describe "DELETE /projects/:id/hooks/:hook_id" do it "should delete hook from project" do expect { - delete api("/projects/#{project.id}/hooks/#{hook.id}", user), - hook_id: hook.id + delete api("/projects/#{project.id}/hooks/#{hook.id}", user) }.to change {project.hooks.count}.by(-1) end end