diff options
author | Luke Picciau <git@itscode.red> | 2019-05-31 10:31:47 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-05-31 10:31:47 +0000 |
commit | 5e8184cc6601bfc690f533b48993904dfe3833eb (patch) | |
tree | 2af8a374496c8841a8d067d6946b1fb9344c795f /app/models/milestone.rb | |
parent | fa32ae5d61e94823aef4d5c040b06b8ea65040a7 (diff) | |
download | gitlab-ce-5e8184cc6601bfc690f533b48993904dfe3833eb.tar.gz |
Change query to work on mysql as well. Also set entire date because setting only the year can trip 'start_date_should_be_less_than_due_date'
Diffstat (limited to 'app/models/milestone.rb')
-rw-r--r-- | app/models/milestone.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 787600569fa..37c129e843a 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -58,6 +58,7 @@ class Milestone < ApplicationRecord validate :uniqueness_of_title, if: :title_changed? validate :milestone_type_check validate :start_date_should_be_less_than_due_date, if: proc { |m| m.start_date.present? && m.due_date.present? } + validate :dates_within_4_digits strip_attributes :title @@ -326,6 +327,16 @@ class Milestone < ApplicationRecord end end + def dates_within_4_digits + if start_date && start_date > Date.new(9999, 12, 31) + errors.add(:start_date, _("date must not be after 9999-12-31")) + end + + if due_date && due_date > Date.new(9999, 12, 31) + errors.add(:due_date, _("date must not be after 9999-12-31")) + end + end + def issues_finder_params { project_id: project_id } end |