Commit 812fc268 authored by Sean McGivern's avatar Sean McGivern

Merge branch '37012-jira-dvcs-error' into 'master'

Fix JIRA DVCS retrieving repositories

Closes #37012

See merge request gitlab-org/gitlab!23180
parents 1965d323 77ed59ee
---
title: Fix JIRA DVCS retrieving repositories
merge_request: 23180
author:
type: fixed
......@@ -117,12 +117,14 @@ module API
namespace = Namespace.find_by_full_path(params[:namespace])
not_found!('Namespace') unless namespace && licensed?(namespace)
projects = Project.public_or_visible_to_user(current_user)
.in_namespace(namespace.self_and_descendants)
.eager_load_namespace_and_owner
.with_route
projects = current_user.can_read_all_resources? ? Project.all : current_user.authorized_projects
projects = projects.in_namespace(namespace.self_and_descendants)
present paginate(projects),
projects_cte = Project.wrap_authorized_projects_with_cte(projects)
.eager_load_namespace_and_owner
.with_route
present paginate(projects_cte),
with: ::API::Github::Entities::Repository,
root_namespace: namespace.root_ancestor
end
......
......@@ -6,12 +6,10 @@ describe API::V3::Github do
let(:user) { create(:user) }
let(:unauthorized_user) { create(:user) }
let(:admin) { create(:user, :admin) }
let!(:project) { create(:project, :repository, creator: user) }
let!(:project2) { create(:project, :repository, creator: user) }
let(:project) { create(:project, :repository, creator: user) }
before do
project.add_maintainer(user)
project2.add_maintainer(user)
stub_licensed_features(jira_dev_panel_integration: true)
end
......@@ -199,6 +197,7 @@ describe API::V3::Github do
end
describe 'repo pulls' do
let(:project2) { create(:project, :repository, creator: user) }
let(:assignee) { create(:user) }
let(:assignee2) { create(:user) }
let!(:merge_request) do
......@@ -208,6 +207,10 @@ describe API::V3::Github do
create(:merge_request, source_project: project2, target_project: project2, author: user, assignees: [assignee, assignee2])
end
before do
project2.add_maintainer(user)
end
describe 'GET /-/jira/pulls' do
it 'returns an array of merge requests with github format' do
jira_get v3_api('/repos/-/jira/pulls', user)
......@@ -283,23 +286,20 @@ describe API::V3::Github do
expect(json_response.size).to eq(projects.size)
end
context 'when instance admin' do
let(:project) { create(:project, group: group) }
it 'returns an array of projects belonging to group with github format' do
expect_project_under_namespace([project], group, create(:user, :admin))
end
end
context 'group namespace' do
let(:project) { create(:project, group: group) }
let!(:project2) { create(:project, :public, group: group) }
before do
group.add_maintainer(user)
it 'returns an array of projects belonging to group excluding the ones user is not directly a member of, even when public' do
expect_project_under_namespace([project], group, user)
end
it 'returns an array of projects belonging to group with github format' do
expect_project_under_namespace([project], group, user)
context 'when instance admin' do
let(:user) { create(:user, :admin) }
it 'returns an array of projects belonging to group' do
expect_project_under_namespace([project, project2], group, user)
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