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

resource_milestone_event.rb « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ba43a1ee3637af3658c217cfc210f56ffb8700c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

class ResourceMilestoneEvent < ApplicationRecord
  include Gitlab::Utils::StrongMemoize
  include Importable
  include ResourceEventTools

  belongs_to :issue
  belongs_to :merge_request
  belongs_to :milestone

  scope :by_issue, ->(issue) { where(issue_id: issue.id) }
  scope :by_merge_request, ->(merge_request) { where(merge_request_id: merge_request.id) }

  enum action: {
         add: 1,
         remove: 2
       }

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

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

  def resource
    issue || merge_request
  end
end