Skip to content
代码片段 群组 项目
提交 26e6eb65 编辑于 作者: Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
浏览文件

Merge branch...

Merge branch '390183-inherited-group-members-selected-as-approvers-are-not-displayed-in-policy-drawer-edit-policy' into 'master'

Query policy group approvers within group hierarchy

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/113114



Merged-by: default avatarDouglas Barbosa Alexandre <dbalexandre@gmail.com>
Approved-by: default avatarVitali Tatarintev <vtatarintev@gitlab.com>
Approved-by: default avatarPavel Shutsin <pshutsin@gitlab.com>
Approved-by: default avatarSashi Kumar Kumaresan <skumar@gitlab.com>
Approved-by: default avatarDouglas Barbosa Alexandre <dbalexandre@gmail.com>
Reviewed-by: default avatarDouglas Barbosa Alexandre <dbalexandre@gmail.com>
Co-authored-by: default avatarDominic Bauer <dbauer@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -35,12 +35,27 @@ def user_approvers(action) ...@@ -35,12 +35,27 @@ def user_approvers(action)
when Project when Project
container.team.users.by_ids_or_usernames(user_ids, user_names) container.team.users.by_ids_or_usernames(user_ids, user_names)
when Group when Group
container.users.by_ids_or_usernames(user_ids, user_names) authorizable_users_in_group_hierarchy_by_ids_or_usernames(user_ids, user_names)
else else
[] []
end end
end end
# rubocop: disable CodeReuse/ActiveRecord
def authorizable_users_in_group_hierarchy_by_ids_or_usernames(user_ids, user_names)
User
.by_ids_or_usernames(user_ids, user_names)
.where(
container
.authorizable_members_with_parents
.merge(Member.where(Member.arel_table[:user_id].eq(User.arel_table[:id])), rewhere: true)
.select(1)
.arel
.exists
)
end
# rubocop: enable CodeReuse/ActiveRecord
def group_approvers(action) def group_approvers(action)
return [] unless action[:group_approvers] || action[:group_approvers_ids] return [] unless action[:group_approvers] || action[:group_approvers_ids]
......
...@@ -52,6 +52,21 @@ ...@@ -52,6 +52,21 @@
expect(response[:users]).to match_array([user]) expect(response[:users]).to match_array([user])
expect(response[:groups]).to be_empty expect(response[:groups]).to be_empty
end end
context 'with user approvers inherited from parent group' do
let(:action) { { type: "require_approval", approvals_required: 1, user_approvers: [user.username] } }
let_it_be(:child) { create(:group, parent: group) }
let(:container) { child }
it 'returns user approvers' do
response = service.execute
expect(response[:status]).to eq(:success)
expect(response[:users]).to match_array([user])
expect(response[:groups]).to be_empty
end
end
end end
context 'with container of any other type' do context 'with container of any other type' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册