From: Jean-Philippe Lang Date: Tue, 16 Dec 2008 21:13:35 +0000 (+0000) Subject: Adds a css class (overdue) to overdue issues on issue lists and detail views (#2337). X-Git-Tag: 0.9.0~870 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2564f05037b0b23b4589b9a005ac89a37810ec68;p=redmine.git Adds a css class (overdue) to overdue issues on issue lists and detail views (#2337). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2140 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index afc8b8559..b9e11c9fa 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -36,6 +36,7 @@ module IssuesHelper # 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 diff --git a/app/models/issue.rb b/app/models/issue.rb index c8befa727..fcac38bde 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -195,6 +195,11 @@ class Issue < ActiveRecord::Base 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 diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 12b4da336..fee6f78c6 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -190,4 +190,11 @@ class IssueTest < Test::Unit::TestCase 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