Skip to content
代码片段 群组 项目
提交 c4a4fc08 编辑于 作者: Vijay Hawoldar's avatar Vijay Hawoldar
浏览文件

Only remove SeatAssignment if no other membership

When removing a user from a group or project, we should only remove
their corresponding SeatAssignment record if the user has no other
membership to any other group or project in the hierarchy

EE: true
Changelog: changed
上级 6e8c7541
No related branches found
No related tags found
无相关合并请求
...@@ -17,7 +17,7 @@ def handle_event(event) ...@@ -17,7 +17,7 @@ def handle_event(event)
return unless user && namespace&.group_namespace? return unless user && namespace&.group_namespace?
return if namespace.billed_project_user?(user) || namespace.billed_group_user?(user) return if ::Member.in_hierarchy(namespace).with_user(user).exists?
GitlabSubscriptions::SeatAssignment.find_by_namespace_and_user(namespace, user)&.destroy GitlabSubscriptions::SeatAssignment.find_by_namespace_and_user(namespace, user)&.destroy
end end
......
...@@ -89,17 +89,25 @@ ...@@ -89,17 +89,25 @@
it_behaves_like 'returns early' it_behaves_like 'returns early'
end end
context 'when user is still billed member of group hierarchy' do context 'when user is still a member of group hierarchy' do
let(:another_sub_group) { create(:group, parent: root_namespace) } let(:another_sub_group) { create(:group, parent: root_namespace) }
before do before do
another_sub_group.add_developer(user) another_sub_group.add_guest(user)
end end
it_behaves_like 'returns early' it_behaves_like 'returns early'
context 'when the user is blocked' do
before do
user.block!
end
it_behaves_like 'returns early'
end
end end
context 'when user is still billed member of project hierarchy' do context 'when user is still a member of project hierarchy' do
let(:project) { build(:project, group: root_namespace) } let(:project) { build(:project, group: root_namespace) }
before do before do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册