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_milestone_event.rb | |
parent | c7e385e282bcb8505589bce526e692b7bb819ffa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/resource_milestone_event.rb')
-rw-r--r-- | app/models/resource_milestone_event.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/models/resource_milestone_event.rb b/app/models/resource_milestone_event.rb new file mode 100644 index 00000000000..ba43a1ee363 --- /dev/null +++ b/app/models/resource_milestone_event.rb @@ -0,0 +1,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 |