diff options
author | Valery Sizov <valery@gitlab.com> | 2016-11-15 19:48:30 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-11-23 13:41:04 +0200 |
commit | 3789cfe056c1d8a5fb91267cc2b1dd0f9f5902a9 (patch) | |
tree | 45314bfcb16ba7095e209d3a1f3eb9be2016b2a6 /app/models/global_milestone.rb | |
parent | d7eeb6df51ffe2ad864ef49d0e465b88ab158520 (diff) | |
download | gitlab-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.rb | 33 |
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 |