diff options
author | Valery Sizov <valery@gitlab.com> | 2016-11-15 19:48:30 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-11-23 13:41:04 +0200 |
commit | 3789cfe056c1d8a5fb91267cc2b1dd0f9f5902a9 (patch) | |
tree | 45314bfcb16ba7095e209d3a1f3eb9be2016b2a6 /app/models/milestone.rb | |
parent | d7eeb6df51ffe2ad864ef49d0e465b88ab158520 (diff) | |
download | gitlab-ce-3789cfe056c1d8a5fb91267cc2b1dd0f9f5902a9.tar.gz |
Add a starting date to milestonesmilestone_start_date
Diffstat (limited to 'app/models/milestone.rb')
-rw-r--r-- | app/models/milestone.rb | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 23aecbfa3a6..c774e69080c 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -29,6 +29,7 @@ class Milestone < ActiveRecord::Base validates :title, presence: true, uniqueness: { scope: :project_id } validates :project, presence: true + validate :start_date_should_be_less_than_due_date, if: Proc.new { |m| m.start_date.present? && m.due_date.present? } strip_attributes :title @@ -131,24 +132,6 @@ class Milestone < ActiveRecord::Base self.title end - def expired? - if due_date - due_date.past? - else - false - end - end - - def expires_at - if due_date - if due_date.past? - "expired on #{due_date.to_s(:medium)}" - else - "expires on #{due_date.to_s(:medium)}" - end - end - end - def can_be_closed? active? && issues.opened.count.zero? end @@ -212,4 +195,10 @@ class Milestone < ActiveRecord::Base def sanitize_title(value) CGI.unescape_html(Sanitize.clean(value.to_s)) end + + def start_date_should_be_less_than_due_date + if due_date <= start_date + errors.add(:start_date, "Can't be greater than due date") + end + end end |