diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-19 21:09:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-19 21:09:10 +0300 |
commit | 33795139ea8e72756bee3675b4e16387425e6ab1 (patch) | |
tree | 3ca568fca61482e57810ee30ad5ce4b964a82c4e /app/models/resource_label_event.rb | |
parent | c7e385e282bcb8505589bce526e692b7bb819ffa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/resource_label_event.rb')
-rw-r--r-- | app/models/resource_label_event.rb | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/app/models/resource_label_event.rb b/app/models/resource_label_event.rb index 98fc9e7bae8..59907f1b962 100644 --- a/app/models/resource_label_event.rb +++ b/app/models/resource_label_event.rb @@ -4,20 +4,17 @@ class ResourceLabelEvent < ApplicationRecord include Importable include Gitlab::Utils::StrongMemoize include CacheMarkdownField + include ResourceEventTools cache_markdown_field :reference - belongs_to :user belongs_to :issue belongs_to :merge_request belongs_to :label - scope :created_after, ->(time) { where('created_at > ?', time) } scope :inc_relations, -> { includes(:label, :user) } - validates :user, presence: { unless: :importing? }, on: :create validates :label, presence: { unless: :importing? }, on: :create - validate :exactly_one_issuable after_save :expire_etag_cache after_destroy :expire_etag_cache @@ -94,22 +91,6 @@ class ResourceLabelEvent < ApplicationRecord end end - def exactly_one_issuable - issuable_count = self.class.issuable_attrs.count { |attr| self["#{attr}_id"] } - - return true if issuable_count == 1 - - # if none of issuable IDs is set, check explicitly if nested issuable - # object is set, this is used during project import - if issuable_count == 0 && importing? - issuable_count = self.class.issuable_attrs.count { |attr| self.public_send(attr) } # rubocop:disable GitlabSecurity/PublicSend - - return true if issuable_count == 1 - end - - errors.add(:base, "Exactly one of #{self.class.issuable_attrs.join(', ')} is required") - end - def expire_etag_cache issuable.expire_note_etag_cache end |