# Returns a string of css classes that apply to the given issue
def css_issue_classes(issue)
s = "issue status-#{issue.status.position} priority-#{issue.priority.position}"
+ s << ' overdue' if issue.overdue?
s
end
self.status.is_closed?
end
+ # Returns true if the issue is overdue
+ def overdue?
+ !due_date.nil? && (due_date < Date.today)
+ end
+
# Users the issue can be assigned to
def assignable_users
project.assignable_users
assert_nil Issue.find_by_id(1)
assert_nil TimeEntry.find_by_issue_id(1)
end
+
+ def test_overdue
+ assert Issue.new(:due_date => 1.day.ago).overdue?
+ assert !Issue.new(:due_date => Date.today).overdue?
+ assert !Issue.new(:due_date => 1.day.from_now).overdue?
+ assert !Issue.new(:due_date => nil).overdue?
+ end
end