Commit a2f2658b authored by Gosia Ksionek's avatar Gosia Ksionek Committed by Stan Hu

Fix Error 500 when inviting user to a few projects

parent 3e5a1f48
---
title: Fix Error 500 when inviting user to a few projects
merge_request: 29778
author:
type: fixed
...@@ -22,6 +22,7 @@ module Gitlab ...@@ -22,6 +22,7 @@ module Gitlab
def check_source_project_membership(user) def check_source_project_membership(user)
return true unless project.forked? return true unless project.forked?
return true unless project.forked_from_project
check_group_managed_account(project.forked_from_project.root_ancestor, user) check_group_managed_account(project.forked_from_project.root_ancestor, user)
end end
......
...@@ -50,6 +50,29 @@ describe Gitlab::Auth::GroupSaml::GmaMembershipEnforcer do ...@@ -50,6 +50,29 @@ describe Gitlab::Auth::GroupSaml::GmaMembershipEnforcer do
end end
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 context 'when project is forked from namespace to group' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:forked_project) { create(:project, namespace: group) } 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