Commit 43566a40 authored by Stan Hu's avatar Stan Hu

Merge branch '214691-error-500-when-inviting-user-to-a-few-projects' into 'master'

Fix Error 500 when inviting user to a few projects

Closes #214691

See merge request gitlab-org/gitlab!29778
parents 29740479 a2f2658b
---
title: Fix Error 500 when inviting user to a few projects
merge_request: 29778
author:
type: fixed
......@@ -22,6 +22,7 @@ module Gitlab
def check_source_project_membership(user)
return true unless project.forked?
return true unless project.forked_from_project
check_group_managed_account(project.forked_from_project.root_ancestor, user)
end
......
......@@ -50,6 +50,29 @@ describe Gitlab::Auth::GroupSaml::GmaMembershipEnforcer do
end
end
context 'when the project is forked from deleted project' do
let!(:forked_project) { fork_project(project, managed_user_for_project) }
before do
project.add_developer(managed_user_for_project)
project.delete
end
context 'when user is group-managed' do
it 'allows adding user to project' do
subject = described_class.new(forked_project)
expect(subject.can_add_user?(managed_user)).to be_truthy
end
end
context 'when user is not group-managed' do
it 'does not allow adding user to project' do
subject = described_class.new(forked_project)
expect(subject.can_add_user?(create(:user))).to be_truthy
end
end
end
context 'when project is forked from namespace to group' do
let(:project) { create(:project) }
let(:forked_project) { create(:project, namespace: group) }
......
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