Commit 03d58f56 authored by Rubén Dávila's avatar Rubén Dávila

Little refactor for milestone_remaining_days helper from last code review.

parent 77731802
......@@ -38,11 +38,10 @@ module MilestonesHelper
end
def milestone_remaining_days(milestone)
days = milestone.remaining_days
if days == 0
if milestone.expired?
content_tag(:strong, 'expired')
elsif days.to_i > 0
elsif milestone.due_date
days = milestone.remaining_days
content = content_tag(:strong, days)
content << " #{'day'.pluralize(days)} remaining"
end
......
......@@ -111,8 +111,7 @@ class Milestone < ActiveRecord::Base
end
def remaining_days
return nil if due_date.nil?
return 0 if due_date < Date.today
return 0 if !due_date || expired?
(due_date - Date.today).to_i
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment