summaryrefslogtreecommitdiff
path: root/app/models/global_milestone.rb
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2016-11-15 19:48:30 +0200
committerValery Sizov <valery@gitlab.com>2016-11-23 13:41:04 +0200
commit3789cfe056c1d8a5fb91267cc2b1dd0f9f5902a9 (patch)
tree45314bfcb16ba7095e209d3a1f3eb9be2016b2a6 /app/models/global_milestone.rb
parentd7eeb6df51ffe2ad864ef49d0e465b88ab158520 (diff)
downloadgitlab-ce-3789cfe056c1d8a5fb91267cc2b1dd0f9f5902a9.tar.gz
Add a starting date to milestonesmilestone_start_date
Diffstat (limited to 'app/models/global_milestone.rb')
-rw-r--r--app/models/global_milestone.rb33
1 files changed, 10 insertions, 23 deletions
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb
index cde4a568577..b01607dcda9 100644
--- a/app/models/global_milestone.rb
+++ b/app/models/global_milestone.rb
@@ -28,26 +28,16 @@ class GlobalMilestone
@title.to_slug.normalize.to_s
end
- def expired?
- if due_date
- due_date.past?
- else
- false
- end
- end
-
def projects
@projects ||= Project.for_milestones(milestones.select(:id))
end
def state
- state = milestones.map { |milestone| milestone.state }
-
- if state.count('closed') == state.size
- 'closed'
- else
- 'active'
+ milestones.each do |milestone|
+ return 'active' if milestone.state != 'closed'
end
+
+ 'closed'
end
def active?
@@ -81,18 +71,15 @@ class GlobalMilestone
@due_date =
if @milestones.all? { |x| x.due_date == @milestones.first.due_date }
@milestones.first.due_date
- else
- nil
end
end
- def expires_at
- if due_date
- if due_date.past?
- "expired on #{due_date.to_s(:medium)}"
- else
- "expires on #{due_date.to_s(:medium)}"
+ def start_date
+ return @start_date if defined?(@start_date)
+
+ @start_date =
+ if @milestones.all? { |x| x.start_date == @milestones.first.start_date }
+ @milestones.first.start_date
end
- end
end
end