BigW Consortium Gitlab

Commit f674b601 by Rémy Coutable Committed by Timothy Andrew

Merge branch 'fix_removing_invited_member' into 'master'

Fix: Deleting an invited member causes 500 error Closes #32504 See merge request !11481
parent acbc5c20
...@@ -10,7 +10,7 @@ module Members ...@@ -10,7 +10,7 @@ module Members
return false if member.is_a?(GroupMember) && member.source.last_owner?(member.user) return false if member.is_a?(GroupMember) && member.source.last_owner?(member.user)
Member.transaction do Member.transaction do
unassign_issues_and_merge_requests(member) unassign_issues_and_merge_requests(member) unless member.invite?
member.destroy member.destroy
end end
......
...@@ -10,5 +10,11 @@ FactoryGirl.define do ...@@ -10,5 +10,11 @@ FactoryGirl.define do
trait(:master) { access_level GroupMember::MASTER } trait(:master) { access_level GroupMember::MASTER }
trait(:owner) { access_level GroupMember::OWNER } trait(:owner) { access_level GroupMember::OWNER }
trait(:access_request) { requested_at Time.now } trait(:access_request) { requested_at Time.now }
trait(:invited) do
user_id nil
invite_token 'xxx'
invite_email 'email@email.com'
end
end end
end end
...@@ -9,5 +9,11 @@ FactoryGirl.define do ...@@ -9,5 +9,11 @@ FactoryGirl.define do
trait(:developer) { access_level ProjectMember::DEVELOPER } trait(:developer) { access_level ProjectMember::DEVELOPER }
trait(:master) { access_level ProjectMember::MASTER } trait(:master) { access_level ProjectMember::MASTER }
trait(:access_request) { requested_at Time.now } trait(:access_request) { requested_at Time.now }
trait(:invited) do
user_id nil
invite_token 'xxx'
invite_email 'email@email.com'
end
end end
end end
...@@ -10,6 +10,27 @@ describe Members::AuthorizedDestroyService, services: true do ...@@ -10,6 +10,27 @@ describe Members::AuthorizedDestroyService, services: true do
Issue.assigned_to(user).count + MergeRequest.assigned_to(user).count Issue.assigned_to(user).count + MergeRequest.assigned_to(user).count
end end
context 'Invited users' do
# Regression spec for issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/32504
it 'destroys invited project member' do
project.team << [member_user, :developer]
member = create :project_member, :invited, project: project
expect { described_class.new(member, member_user).execute }
.to change { Member.count }.from(2).to(1)
end
it 'destroys invited group member' do
group.add_developer(member_user)
member = create :group_member, :invited, group: group
expect { described_class.new(member, member_user).execute }
.to change { Member.count }.from(2).to(1)
end
end
context 'Group member' do context 'Group member' do
it "unassigns issues and merge requests" do it "unassigns issues and merge requests" do
group.add_developer(member_user) group.add_developer(member_user)
......
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