From 961a6bfcc2f0b1063445143ba8841e6c6dcea8bf Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 30 Oct 2014 17:28:59 +0200 Subject: API delete branch: render branch name json instead of true Signed-off-by: Dmitriy Zaporozhets --- app/controllers/projects/branches_controller.rb | 1 + lib/api/branches.rb | 5 ++++- spec/requests/api/branches_spec.rb | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index dd6df5d196b..9f50660a5ad 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -19,6 +19,7 @@ class Projects::BranchesController < Projects::ApplicationController def create result = CreateBranchService.new(project, current_user). execute(params[:branch_name], params[:ref]) + if result[:status] == :success @branch = result[:branch] redirect_to project_tree_path(@project, @branch.name) diff --git a/lib/api/branches.rb b/lib/api/branches.rb index 14f8b20f6b2..6ec1a753a69 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -82,6 +82,7 @@ module API authorize_push_project result = CreateBranchService.new(user_project, current_user). execute(params[:branch_name], params[:ref]) + if result[:status] == :success present result[:branch], with: Entities::RepoObject, @@ -104,7 +105,9 @@ module API execute(params[:branch]) if result[:status] == :success - true + { + branch_name: params[:branch] + } else render_api_error!(result[:message], result[:return_code]) end diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index 8834a6cfa83..b45572c39fd 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -146,6 +146,7 @@ describe API::API, api: true do it "should remove branch" do delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user) response.status.should == 200 + json_response['branch_name'].should == branch_name end it 'should return 404 if branch not exists' do -- cgit v1.2.1 From 20e04d9f398b1f4221fa9f5de529dea7c2f0f9c1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 30 Oct 2014 17:30:09 +0200 Subject: Delete branch via API: doc updated Signed-off-by: Dmitriy Zaporozhets --- doc/api/branches.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/api/branches.md b/doc/api/branches.md index 74386615545..319f0b47386 100644 --- a/doc/api/branches.md +++ b/doc/api/branches.md @@ -211,3 +211,11 @@ Parameters: It return 200 if succeed, 404 if the branch to be deleted does not exist or 400 for other reasons. In case of an error, an explaining message is provided. + +Success response: + +```json +{ + "branch_name": "my-removed-branch" +} +``` -- cgit v1.2.1