]> source.dussan.org Git - redmine.git/commitdiff
Adds a css class (overdue) to overdue issues on issue lists and detail views (#2337).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 16 Dec 2008 21:13:35 +0000 (21:13 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 16 Dec 2008 21:13:35 +0000 (21:13 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2140 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/issues_helper.rb
app/models/issue.rb
test/unit/issue_test.rb

index afc8b8559a19221e5eb0cd722b9fbe8df1c637c0..b9e11c9faabc79a98d0a76de074654040294c4b3 100644 (file)
@@ -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
   
index c8befa727a7b5ea2dba6603bc478399d8abb2f7e..fcac38bdeab46eb01c0051af25cfa16223c4d11e 100644 (file)
@@ -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
index 12b4da33619cd3add3c0500a897eb55d7c5b47b0..fee6f78c655168aedc19ab6337b96790c5ec6e62 100644 (file)
@@ -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