diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-06 06:09:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-06 06:09:47 +0300 |
commit | e6f1de5a8fc0a18647d4ff8cff0a50988dcb8e99 (patch) | |
tree | da13bf56be4175700d78b7b1ed0c49899b37be70 /app/models | |
parent | 4aa03ea3561b0a36dbbb8dd83c34163184ad5a61 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/enums/issuable_link.rb | 12 | ||||
-rw-r--r-- | app/models/concerns/issuable_link.rb | 5 | ||||
-rw-r--r-- | app/models/work_items/related_link_restriction.rb | 16 |
3 files changed, 30 insertions, 3 deletions
diff --git a/app/models/concerns/enums/issuable_link.rb b/app/models/concerns/enums/issuable_link.rb new file mode 100644 index 00000000000..ca5728c2600 --- /dev/null +++ b/app/models/concerns/enums/issuable_link.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Enums + module IssuableLink + TYPE_RELATES_TO = 'relates_to' + TYPE_BLOCKS = 'blocks' + + def self.link_types + { TYPE_RELATES_TO => 0, TYPE_BLOCKS => 1 } + end + end +end diff --git a/app/models/concerns/issuable_link.rb b/app/models/concerns/issuable_link.rb index 4a922d3c2ea..dcd2705185f 100644 --- a/app/models/concerns/issuable_link.rb +++ b/app/models/concerns/issuable_link.rb @@ -10,8 +10,7 @@ module IssuableLink extend ActiveSupport::Concern MAX_LINKS_COUNT = 100 - TYPE_RELATES_TO = 'relates_to' - TYPE_BLOCKS = 'blocks' ## EE-only. Kept here to be used on link_type enum. + TYPE_RELATES_TO = Enums::IssuableLink::TYPE_RELATES_TO class_methods do def inverse_link_type(type) @@ -43,7 +42,7 @@ module IssuableLink scope :for_source_or_target, ->(issuable) { where(source: issuable).or(where(target: issuable)) } - enum link_type: { TYPE_RELATES_TO => 0, TYPE_BLOCKS => 1 } + enum link_type: Enums::IssuableLink.link_types private diff --git a/app/models/work_items/related_link_restriction.rb b/app/models/work_items/related_link_restriction.rb new file mode 100644 index 00000000000..d4a66c95ffb --- /dev/null +++ b/app/models/work_items/related_link_restriction.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module WorkItems + class RelatedLinkRestriction < ApplicationRecord + self.table_name = 'work_item_related_link_restrictions' + + belongs_to :source_type, class_name: 'WorkItems::Type' + belongs_to :target_type, class_name: 'WorkItems::Type' + + validates :source_type, presence: true + validates :target_type, presence: true + validates :target_type, uniqueness: { scope: [:source_type_id, :link_type] } + + enum link_type: Enums::IssuableLink.link_types + end +end |