Commit eea92c4e authored by Kerri Miller's avatar Kerri Miller

Add section to name uniqueness validation

parent bedde99a
......@@ -26,7 +26,7 @@ class ApprovalMergeRequestRule < ApplicationRecord
scope :code_owner_approval_optional, -> { code_owner.where(approvals_required: 0) }
scope :code_owner_approval_required, -> { code_owner.where('approvals_required > 0') }
validates :name, uniqueness: { scope: [:merge_request_id, :rule_type] }
validates :name, uniqueness: { scope: [:merge_request_id, :rule_type, :section] }
validates :rule_type, uniqueness: { scope: :merge_request_id, message: proc { _('any-approver for the merge request already exists') } }, if: :any_approver?
validates :report_type, presence: true, if: :report_approver?
# Temporary validations until `code_owner` can be dropped in favor of `rule_type`
......
......@@ -17,7 +17,7 @@ describe ApprovalMergeRequestRule do
end
it 'is invalid when name not unique within rule type and merge request' do
is_expected.to validate_uniqueness_of(:name).scoped_to([:merge_request_id, :rule_type])
is_expected.to validate_uniqueness_of(:name).scoped_to([:merge_request_id, :rule_type, :section])
end
context 'approval_project_rule is set' 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