Fix branch API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
66ef5c1aa2
commit
eaeb4a90d4
|
|
@ -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
|
||||||
# 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
|
||||||
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
|
||||||
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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue