Patch #12737 ยป no_negative_duration.diff
| app/models/issue.rb | ||
|---|---|---|
|
validates_length_of :subject, :maximum => 255
|
||
|
validates_inclusion_of :done_ratio, :in => 0..100
|
||
|
validates_numericality_of :estimated_hours, :allow_nil => true
|
||
|
validate :validate_issue, :validate_required_fields
|
||
|
validate :validate_issue, :validate_required_fields, :validate_estimated_hours
|
||
|
scope :visible, lambda {|*args|
|
||
|
includes(:project).where(Issue.visible_condition(args.shift || User.current, *args))
|
||
| ... | ... | |
|
self.priority ||= IssuePriority.default
|
||
|
self.watcher_user_ids = []
|
||
|
end
|
||
|
self.estimated_hours = nil if estimated_hours == 0
|
||
|
end
|
||
|
# AR#Persistence#destroy would raise and RecordNotFound exception
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def validate_estimated_hours
|
||
|
errors.add :estimated_hours, :invalid if estimated_hours && (estimated_hours < 0 || estimated_hours >= 1000)
|
||
|
end
|
||
|
# Set the done_ratio using the status if that setting is set. This will keep the done_ratios
|
||
|
# even if the user turns off the setting later
|
||