From ad47993ac46cef672600f2384ee5fa2e661ec8be Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sun, 21 Sep 2014 10:29:52 +0200 Subject: Factor error and success methods from services. --- lib/api/branches.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/api/branches.rb') diff --git a/lib/api/branches.rb b/lib/api/branches.rb index 4db5f61dd28..75783628e3d 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -80,10 +80,8 @@ module API # POST /projects/:id/repository/branches post ":id/repository/branches" do authorize_push_project - result = CreateBranchService.new.execute(user_project, - params[:branch_name], - params[:ref], - current_user) + result = CreateBranchService.new(user_project, current_user). + execute(params[:branch_name], params[:ref]) if result[:status] == :success present result[:branch], with: Entities::RepoObject, @@ -102,9 +100,10 @@ module API # DELETE /projects/:id/repository/branches/:branch delete ":id/repository/branches/:branch" do authorize_push_project - result = DeleteBranchService.new.execute(user_project, params[:branch], current_user) + result = DeleteBranchService.new(user_project, current_user). + execute(params[:branch]) - if result[:state] == :success + if result[:status] == :success true else render_api_error!(result[:message], result[:return_code]) -- cgit v1.2.1