2020-02-19 13:09:10 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-01 19:07:41 -05:00
|
|
|
class ResourceMilestoneEvent < ResourceEvent
|
2020-03-23 11:09:36 -04:00
|
|
|
include IgnorableColumns
|
2020-05-07 08:09:46 -04:00
|
|
|
include IssueResourceEvent
|
|
|
|
include MergeRequestResourceEvent
|
2020-03-23 11:09:36 -04:00
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
belongs_to :milestone
|
|
|
|
|
2020-03-01 19:07:41 -05:00
|
|
|
validate :exactly_one_issuable
|
|
|
|
|
2020-05-26 11:08:17 -04:00
|
|
|
scope :include_relations, -> { includes(:user, milestone: [:project, :group]) }
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
enum action: {
|
2020-04-21 11:21:10 -04:00
|
|
|
add: 1,
|
|
|
|
remove: 2
|
|
|
|
}
|
2020-02-19 13:09:10 -05:00
|
|
|
|
|
|
|
# state is used for issue and merge request states.
|
|
|
|
enum state: Issue.available_states.merge(MergeRequest.available_states)
|
|
|
|
|
2020-03-23 11:09:36 -04:00
|
|
|
ignore_columns %i[reference reference_html cached_markdown_version], remove_with: '13.1', remove_after: '2020-06-22'
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
def self.issuable_attrs
|
|
|
|
%i(issue merge_request).freeze
|
|
|
|
end
|
2020-04-27 11:10:16 -04:00
|
|
|
|
|
|
|
def milestone_title
|
|
|
|
milestone&.title
|
|
|
|
end
|
2020-05-26 11:08:17 -04:00
|
|
|
|
|
|
|
def milestone_parent
|
|
|
|
milestone&.parent
|
|
|
|
end
|
|
|
|
|
|
|
|
def issuable
|
|
|
|
issue || merge_request
|
|
|
|
end
|
2020-02-19 13:09:10 -05:00
|
|
|
end
|