Commit af146726 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '39068-gitlab-admin-merge-request-jira' into 'master'

Fixed GitLab admin not seeing merge requests

See merge request gitlab-org/gitlab!21467
parents eff38573 05622a5f
---
title: Fixed GitLab admin not seeing merge requests in Jira Development Panel Integration
merge_request: 21467
author:
type: fixed
...@@ -75,11 +75,11 @@ module API ...@@ -75,11 +75,11 @@ module API
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def authorized_merge_requests def authorized_merge_requests
MergeRequestsFinder.new(current_user, authorized_only: true).execute MergeRequestsFinder.new(current_user, authorized_only: !current_user.admin?).execute
end end
def authorized_merge_requests_for_project(project) def authorized_merge_requests_for_project(project)
MergeRequestsFinder.new(current_user, authorized_only: true, project_id: project.id).execute MergeRequestsFinder.new(current_user, authorized_only: !current_user.admin?, project_id: project.id).execute
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -5,6 +5,7 @@ require 'spec_helper' ...@@ -5,6 +5,7 @@ require 'spec_helper'
describe API::V3::Github do describe API::V3::Github do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:unauthorized_user) { create(:user) } let(:unauthorized_user) { create(:user) }
let(:admin) { create(:user, :admin) }
let!(:project) { create(:project, :repository, creator: user) } let!(:project) { create(:project, :repository, creator: user) }
let!(:project2) { create(:project, :repository, creator: user) } let!(:project2) { create(:project, :repository, creator: user) }
...@@ -230,6 +231,7 @@ describe API::V3::Github do ...@@ -230,6 +231,7 @@ describe API::V3::Github do
end end
describe 'GET /repos/:namespace/:project/pulls/:id' do describe 'GET /repos/:namespace/:project/pulls/:id' do
context 'when user has access to the merge requests' do
it 'returns the requested merge request in github format' do it 'returns the requested merge request in github format' do
jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/pulls/#{merge_request.id}", user) jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/pulls/#{merge_request.id}", user)
...@@ -237,6 +239,26 @@ describe API::V3::Github do ...@@ -237,6 +239,26 @@ describe API::V3::Github do
expect(response).to match_response_schema('entities/github/pull_request', dir: 'ee') expect(response).to match_response_schema('entities/github/pull_request', dir: 'ee')
end end
end end
context 'when user has no access to the merge request' do
it 'returns 404' do
project.add_guest(unauthorized_user)
jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/pulls/#{merge_request.id}", unauthorized_user)
expect(response).to have_gitlab_http_status(404)
end
end
context 'when instance admin' do
it 'returns the requested merge request in github format' do
jira_get v3_api("/repos/#{project.namespace.path}/#{project.path}/pulls/#{merge_request.id}", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('entities/github/pull_request', dir: 'ee')
end
end
end
end end
describe 'GET /users/:namespace/repos' do describe 'GET /users/:namespace/repos' 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