Fix branch API

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-09-25 16:22:08 +03:00
parent 66ef5c1aa2
commit eaeb4a90d4
No known key found for this signature in database
GPG Key ID: 161B5D6A44D3D88A
3 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ module API
# Example Request:
# GET /projects/:id/repository/branches
get ":id/repository/branches" do
present user_project.repo.heads.sort_by(&:name), with: Entities::RepoObject, project: user_project
present user_project.repository.branches.sort_by(&:name), with: Entities::RepoObject, project: user_project
end
# Get a single branch
@ -25,7 +25,7 @@ module API
# Example Request:
# GET /projects/:id/repository/branches/:branch
get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do
@branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
@branch = user_project.repository.branches.find { |item| item.name == params[:branch] }
not_found!("Branch does not exist") if @branch.nil?
present @branch, with: Entities::RepoObject, project: user_project
end

View File

@ -36,7 +36,7 @@ describe WikiPage do
end
it "sets the version attribute" do
@wiki_page.version.should be_a Commit
@wiki_page.version.should be_a Grit::Commit
end
end
end

View File

@ -17,7 +17,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/branches", user)
response.status.should == 200
json_response.should be_an Array
json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name
json_response.first['name'].should == project.repository.branch_names.first
end
end