Skip to content
代码片段 群组 项目
未验证 提交 e7928dc1 编辑于 作者: Gavin Hinfey's avatar Gavin Hinfey 提交者: GitLab
浏览文件

Allow only top level groups for ApprovalGroupRules

上级 ae77671e
No related branches found
No related tags found
无相关合并请求
...@@ -21,6 +21,7 @@ class ApprovalGroupRule < ApplicationRecord ...@@ -21,6 +21,7 @@ class ApprovalGroupRule < ApplicationRecord
scope: :group_id, scope: :group_id,
message: proc { _('any-approver for the group already exists') } message: proc { _('any-approver for the group already exists') }
}, if: :any_approver? }, if: :any_approver?
validates :group, presence: true, top_level_group: true
def audit_add(_model) def audit_add(_model)
# currently no audit on group add, only on project. # currently no audit on group add, only on project.
......
...@@ -23,6 +23,23 @@ ...@@ -23,6 +23,23 @@
'Validation failed: Applies to all protected branches must be enabled.') 'Validation failed: Applies to all protected branches must be enabled.')
end end
end end
context 'for groups' do
let_it_be(:parent) { create(:group) }
let_it_be(:child) { create(:group, parent: parent) }
it 'supports top level groups' do
group_approval_rule.update!(group: parent)
expect(group_approval_rule.group).to eq(parent)
end
it 'child groups are not supported' do
expect do
group_approval_rule.update!(group: child)
end.to raise_error(ActiveRecord::RecordInvalid,
'Validation failed: Group must be a top level Group')
end
end
end end
describe 'associations' do describe 'associations' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册