Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-02-21 18:19:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-21 18:19:50 +0300
commit871e82b7c73283c2c71355e3258a6c9d3b8c0eda (patch)
treee895b27d313e8df94a160e4820093d0bc25d5a4c /app/models/issue_link.rb
parentda9274a8f1939c135f3427947407680faa290052 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/issue_link.rb')
-rw-r--r--app/models/issue_link.rb35
1 files changed, 3 insertions, 32 deletions
diff --git a/app/models/issue_link.rb b/app/models/issue_link.rb
index 920586cc1ba..ecf9f2eaf6c 100644
--- a/app/models/issue_link.rb
+++ b/app/models/issue_link.rb
@@ -2,47 +2,18 @@
class IssueLink < ApplicationRecord
include FromUnion
+ include IssuableLink
belongs_to :source, class_name: 'Issue'
belongs_to :target, class_name: 'Issue'
- validates :source, presence: true
- validates :target, presence: true
- validates :source, uniqueness: { scope: :target_id, message: 'is already related' }
- validate :check_self_relation
- validate :check_opposite_relation
-
scope :for_source_issue, ->(issue) { where(source_id: issue.id) }
scope :for_target_issue, ->(issue) { where(target_id: issue.id) }
- TYPE_RELATES_TO = 'relates_to'
- TYPE_BLOCKS = 'blocks'
- # we don't store is_blocked_by in the db but need it for displaying the relation
- # from the target (used in IssueLink.inverse_link_type)
- TYPE_IS_BLOCKED_BY = 'is_blocked_by'
-
- enum link_type: { TYPE_RELATES_TO => 0, TYPE_BLOCKS => 1 }
-
- def self.inverse_link_type(type)
- type
- end
-
private
- def check_self_relation
- return unless source && target
-
- if source == target
- errors.add(:source, 'cannot be related to itself')
- end
- end
-
- def check_opposite_relation
- return unless source && target
-
- if IssueLink.find_by(source: target, target: source)
- errors.add(:source, 'is already related to this issue')
- end
+ def issuable_type
+ :issue
end
end