Commit fd9e67a5 authored by Mark Chao's avatar Mark Chao

Merge branch '331329-bugfix-api-v3-branches-when-project-has-no-repo' into 'master'

Handle when if project has no repository

See merge request gitlab-org/gitlab!67296
parents 7c6f815d d06ebcf7
......@@ -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