From 7e9c479f7de77702622631cff2628a9c8dcbc627 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 19 Nov 2020 08:27:35 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-6-stable-ee --- app/models/design_management/design.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/models/design_management/design.rb') diff --git a/app/models/design_management/design.rb b/app/models/design_management/design.rb index 62e4bd6cebc..f5e52c04944 100644 --- a/app/models/design_management/design.rb +++ b/app/models/design_management/design.rb @@ -2,6 +2,7 @@ module DesignManagement class Design < ApplicationRecord + include AtomicInternalId include Importable include Noteable include Gitlab::FileTypeDetection @@ -10,12 +11,15 @@ module DesignManagement include Mentionable include WhereComposite include RelativePositioning + include Todoable + include Participable belongs_to :project, inverse_of: :designs belongs_to :issue has_many :actions has_many :versions, through: :actions, class_name: 'DesignManagement::Version', inverse_of: :designs + has_many :authors, -> { distinct }, through: :versions, class_name: 'User' # This is a polymorphic association, so we can't count on FK's to delete the # data has_many :notes, as: :noteable, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent @@ -23,6 +27,10 @@ module DesignManagement has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent + has_internal_id :iid, scope: :project, presence: true, + hook_names: %i[create update], # Deal with old records + track_if: -> { !importing? } + validates :project, :filename, presence: true validates :issue, presence: true, unless: :importing? validates :filename, uniqueness: { scope: :issue_id }, length: { maximum: 255 } @@ -30,6 +38,9 @@ module DesignManagement alias_attribute :title, :filename + participant :authors + participant :notes_with_associations + # Pre-fetching scope to include the data necessary to construct a # reference using `to_reference`. scope :for_reference, -> { includes(issue: [{ project: [:route, :namespace] }]) } -- cgit v1.2.3