summaryrefslogtreecommitdiff
path: root/app/models/resource_state_event.rb
blob: 1ce4e14d2899f46cf2d9841314c347ca358b9adb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class ResourceStateEvent < ResourceEvent
  include IssueResourceEvent
  include MergeRequestResourceEvent

  validate :exactly_one_issuable

  belongs_to :source_merge_request, class_name: 'MergeRequest', foreign_key: :source_merge_request_id

  # state is used for issue and merge request states.
  enum state: Issue.available_states.merge(MergeRequest.available_states).merge(reopened: 5)

  def self.issuable_attrs
    %i(issue merge_request).freeze
  end

  def issuable
    issue || merge_request
  end
end

ResourceStateEvent.prepend_if_ee('EE::ResourceStateEvent')