diff app/models/version.rb @ 514:7eba09d624db live

Merge
author Chris Cannam
date Thu, 14 Jul 2011 10:50:53 +0100
parents 0c939c159af4
children cbb26bc654de
line wrap: on
line diff
--- a/app/models/version.rb	Thu Jul 14 10:46:20 2011 +0100
+++ b/app/models/version.rb	Thu Jul 14 10:50:53 2011 +0100
@@ -33,6 +33,7 @@
   validates_inclusion_of :status, :in => VERSION_STATUSES
   validates_inclusion_of :sharing, :in => VERSION_SHARINGS
 
+  named_scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
   named_scope :open, :conditions => {:status => 'open'}
   named_scope :visible, lambda {|*args| { :include => :project,
                                           :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
@@ -43,7 +44,7 @@
   end
   
   def start_date
-    effective_date
+    @start_date ||= fixed_issues.minimum('start_date')
   end
   
   def due_date
@@ -77,8 +78,7 @@
   def behind_schedule?
     if completed_pourcent == 100
       return false
-    elsif due_date && fixed_issues.present? && fixed_issues.minimum('start_date') # TODO: should use #start_date but that method is wrong...
-      start_date = fixed_issues.minimum('start_date')
+    elsif due_date && start_date
       done_date = start_date + ((due_date - start_date+1)* completed_pourcent/100).floor
       return done_date <= Date.today
     else