Commit e81a28b3 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '215194-add-section-to-name-uniqueness-validation' into 'master'

Add section to name uniqueness validation

See merge request gitlab-org/gitlab!33119
parents d2b1a6b9 eea92c4e
......@@ -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 @@ RSpec.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