Project

General

Profile

Patch #12737 ยป no_negative_duration.diff

Patch for negative duration - Daniel Felix, 2013-01-04 15:14

View differences:

app/models/issue.rb
68 68
  validates_length_of :subject, :maximum => 255
69 69
  validates_inclusion_of :done_ratio, :in => 0..100
70 70
  validates_numericality_of :estimated_hours, :allow_nil => true
71
  validate :validate_issue, :validate_required_fields
71
  validate :validate_issue, :validate_required_fields, :validate_estimated_hours
72 72

  
73 73
  scope :visible, lambda {|*args|
74 74
    includes(:project).where(Issue.visible_condition(args.shift || User.current, *args))
......
147 147
      self.priority ||= IssuePriority.default
148 148
      self.watcher_user_ids = []
149 149
    end
150
    self.estimated_hours = nil if estimated_hours == 0
150 151
  end
151 152

  
152 153
  # AR#Persistence#destroy would raise and RecordNotFound exception
......
600 601
      end
601 602
    end
602 603
  end
604
  
605
  def validate_estimated_hours
606
    errors.add :estimated_hours, :invalid if estimated_hours && (estimated_hours < 0 || estimated_hours >= 1000)
607
  end
603 608

  
604 609
  # Set the done_ratio using the status if that setting is set.  This will keep the done_ratios
605 610
  # even if the user turns off the setting later
    (1-1/1)