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 ...@@ -38,11 +38,10 @@ module MilestonesHelper
end end
def milestone_remaining_days(milestone) def milestone_remaining_days(milestone)
days = milestone.remaining_days if milestone.expired?
if days == 0
content_tag(:strong, 'expired') content_tag(:strong, 'expired')
elsif days.to_i > 0 elsif milestone.due_date
days = milestone.remaining_days
content = content_tag(:strong, days) content = content_tag(:strong, days)
content << " #{'day'.pluralize(days)} remaining" content << " #{'day'.pluralize(days)} remaining"
end end
......
...@@ -111,8 +111,7 @@ class Milestone < ActiveRecord::Base ...@@ -111,8 +111,7 @@ class Milestone < ActiveRecord::Base
end end
def remaining_days def remaining_days
return nil if due_date.nil? return 0 if !due_date || expired?
return 0 if due_date < Date.today
(due_date - Date.today).to_i (due_date - Date.today).to_i
end 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