Commit d06ebcf7 authored by Luke Duncalfe's avatar Luke Duncalfe Committed by Mark Chao

Handle when if project has no repository

parent 4e282783
......@@ -214,6 +214,8 @@ module API
update_project_feature_usage_for(user_project)
next [] unless user_project.repo_exists?
branches = ::Kaminari.paginate_array(user_project.repository.branches.sort_by(&:name))
present paginate(branches), with: ::API::Github::Entities::Branch, project: user_project
......
......@@ -472,6 +472,17 @@ RSpec.describe API::V3::Github do
expect(response).to have_gitlab_http_status(:ok)
end
context 'when the project has no repository', :aggregate_failures do
let_it_be(:project) { create(:project, creator: user) }
it 'returns an empty collection response' do
jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", user)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty
end
end
end
context 'unauthenticated' do
......
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