debian-mirror-gitlab/app/models/resource_milestone_event.rb

40 lines
830 B
Ruby
Raw Normal View History

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