diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-28 00:09:08 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-28 00:09:08 +0000 |
commit | f54a50aa826d0eedcf2e56f51462613bc132f826 (patch) | |
tree | 7194aca23f9af822ea55966a6f477b3d8d68ee47 /app/models/milestone.rb | |
parent | c77fda905a8619b756163c10a75171dc9cfe7084 (diff) | |
download | gitlab-ce-f54a50aa826d0eedcf2e56f51462613bc132f826.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/milestone.rb')
-rw-r--r-- | app/models/milestone.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 29c621c54d0..4ccfe314526 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -3,7 +3,13 @@ class Milestone < ApplicationRecord # Represents a "No Milestone" state used for filtering Issues and Merge # Requests that have no milestone assigned. - MilestoneStruct = Struct.new(:title, :name, :id) + MilestoneStruct = Struct.new(:title, :name, :id) do + # Ensure these models match the interface required for exporting + def serializable_hash(_opts = {}) + { title: title, name: name, id: id } + end + end + None = MilestoneStruct.new('No Milestone', 'No Milestone', 0) Any = MilestoneStruct.new('Any Milestone', '', -1) Upcoming = MilestoneStruct.new('Upcoming', '#upcoming', -2) @@ -128,11 +134,12 @@ class Milestone < ApplicationRecord reorder(nil).group(:state).count end + def predefined_id?(id) + [Any.id, None.id, Upcoming.id, Started.id].include?(id) + end + def predefined?(milestone) - milestone == Any || - milestone == None || - milestone == Upcoming || - milestone == Started + predefined_id?(milestone&.id) end end |