Commit bf470fc9 authored by Igor Drozdov's avatar Igor Drozdov

Allow to delete any-approval rule using API call

User defined rules are allowed to be deleted
parent 17389160
......@@ -50,4 +50,8 @@ module ApprovalRuleLike
def any_approver?
raise NotImplementedError
end
def user_defined?
regular? || any_approver?
end
end
......@@ -4,7 +4,7 @@ class ApprovalMergeRequestRulePolicy < BasePolicy
delegate { @subject.merge_request }
condition(:editable) do
can?(:update_merge_request, @subject.merge_request) && @subject.regular?
can?(:update_merge_request, @subject.merge_request) && @subject.user_defined?
end
rule { editable }.enable :edit_approval_rule
......
......@@ -15,7 +15,15 @@ describe ApprovalMergeRequestRulePolicy do
expect(permissions(merge_request.author, approval_rule)).to be_allowed(:edit_approval_rule)
end
context 'when rule is not regular type' do
context 'when rule is any-approval' do
let(:approval_rule) { build(:any_approver_rule, merge_request: merge_request) }
it 'allows updating approval rule' do
expect(permissions(merge_request.author, approval_rule)).to be_allowed(:edit_approval_rule)
end
end
context 'when rule is not user editable' do
let(:approval_rule) { create(:code_owner_rule, merge_request: merge_request) }
it 'disallows updating approval rule' do
......
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