diff options
author | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-14 16:55:33 +0100 |
---|---|---|
committer | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-14 16:55:33 +0100 |
commit | c305eb31aa1cf1aec24b907e0db1d7b2084400dc (patch) | |
tree | 9df3cf267fd31e617bac562d77c8df0afed7c5a0 /lib/api/projects.rb | |
parent | 6df02adc7a5cb7badf748be783f9a552cf19aeee (diff) | |
download | gitlab-ce-c305eb31aa1cf1aec24b907e0db1d7b2084400dc.tar.gz |
API: tests that check status codes for project branches and hooks
Status code 422 (Unprocessable Entity) returned if invalid url is given when creating
or updating a project hook.
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 87653f04450..cf3e8257a77 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -156,9 +156,9 @@ module Gitlab # DELETE /projects/:id/members/:user_id delete ":id/members/:user_id" do authorize! :admin_project, user_project - users_project = user_project.users_projects.find_by_user_id params[:user_id] - unless users_project.nil? - users_project.destroy + team_member = user_project.users_projects.find_by_user_id(params[:user_id]) + unless team_member.nil? + team_member.destroy else {:message => "Access revoked", :id => params[:user_id].to_i} end @@ -205,6 +205,9 @@ module Gitlab if @hook.save present @hook, with: Entities::Hook else + if @hook.errors[:url].present? + error!("Invalid url given", 422) + end not_found! end end @@ -227,6 +230,9 @@ module Gitlab if @hook.update_attributes attrs present @hook, with: Entities::Hook else + if @hook.errors[:url].present? + error!("Invalid url given", 422) + end not_found! end end @@ -281,6 +287,7 @@ module Gitlab # PUT /projects/:id/repository/branches/:branch/protect put ":id/repository/branches/:branch/protect" do @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } + not_found! unless @branch protected = user_project.protected_branches.find_by_name(@branch.name) unless protected @@ -299,6 +306,7 @@ module Gitlab # PUT /projects/:id/repository/branches/:branch/unprotect put ":id/repository/branches/:branch/unprotect" do @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } + not_found! unless @branch protected = user_project.protected_branches.find_by_name(@branch.name) if protected |