Commit eaeb4a90 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix branch API

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 66ef5c1a
...@@ -14,7 +14,7 @@ module API ...@@ -14,7 +14,7 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/repository/branches # GET /projects/:id/repository/branches
get ":id/repository/branches" do 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 end
# Get a single branch # Get a single branch
...@@ -25,7 +25,7 @@ module API ...@@ -25,7 +25,7 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/repository/branches/:branch # GET /projects/:id/repository/branches/:branch
get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do 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? not_found!("Branch does not exist") if @branch.nil?
present @branch, with: Entities::RepoObject, project: user_project present @branch, with: Entities::RepoObject, project: user_project
end end
......
...@@ -36,7 +36,7 @@ describe WikiPage do ...@@ -36,7 +36,7 @@ describe WikiPage do
end end
it "sets the version attribute" do it "sets the version attribute" do
@wiki_page.version.should be_a Commit @wiki_page.version.should be_a Grit::Commit
end end
end end
end end
......
...@@ -17,7 +17,7 @@ describe API::API, api: true do ...@@ -17,7 +17,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/branches", user) get api("/projects/#{project.id}/repository/branches", user)
response.status.should == 200 response.status.should == 200
json_response.should be_an Array 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
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment