Accessing a repository branch that does not exist returns a 404 error instead
of 200 now. Added a test.
# GET /projects/:id/repository/branches/:branch
get ":id/repository/branches/:branch" do
@branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
+ error!("Branch does not exist", 404) if @branch.nil?
present @branch, with: Entities::RepoObject, project: user_project
end
json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1'
json_response['protected'].should == false
end
+
+ it "should return a 404 error if branch is not available" do
+ get api("/projects/#{project.id}/repository/branches/unknown", user)
+ response.status.should == 404
+ end
end
describe "PUT /projects/:id/repository/branches/:branch/protect" do