Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
424dfdfe
Commit
424dfdfe
authored
May 31, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
2c9e17b6
ed7c8e70
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
16 deletions
+74
-16
app/models/milestone.rb
app/models/milestone.rb
+11
-0
changelogs/unreleased/add-constraint-for-milestone-dates.yml
changelogs/unreleased/add-constraint-for-milestone-dates.yml
+5
-0
db/migrate/20190523112344_limit_milestone_date_years_to_4_digits.rb
.../20190523112344_limit_milestone_date_years_to_4_digits.rb
+38
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+17
-16
No files found.
app/models/milestone.rb
View file @
424dfdfe
...
...
@@ -60,6 +60,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
...
...
@@ -328,6 +329,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
...
...
changelogs/unreleased/add-constraint-for-milestone-dates.yml
0 → 100644
View file @
424dfdfe
---
title
:
Limit milestone dates to before year
9999
merge_request
:
28742
author
:
Luke Picciau
type
:
fixed
db/migrate/20190523112344_limit_milestone_date_years_to_4_digits.rb
0 → 100644
View file @
424dfdfe
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
LimitMilestoneDateYearsTo4Digits
<
ActiveRecord
::
Migration
[
5.1
]
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
# DOWNTIME_REASON = ''
# When using the methods "add_concurrent_index", "remove_concurrent_index" or
# "add_column_with_default" you must disable the use of transactions
# as these methods can not run in an existing transaction.
# When using "add_concurrent_index" or "remove_concurrent_index" methods make sure
# that either of them is the _only_ method called in the migration,
# any other changes should go in a separate migration.
# This ensures that upon failure _only_ the index creation or removing fails
# and can be retried or reverted easily.
#
# To disable transactions uncomment the following line and remove these
# comments:
# disable_ddl_transaction!
def
change
Milestone
.
where
(
"start_date > '9999-12-31'"
).
update_all
(
"start_date = '9999-12-31'"
)
Milestone
.
where
(
"due_date > '9999-12-31'"
).
update_all
(
"due_date = '9999-12-31'"
)
end
end
locale/gitlab.pot
View file @
424dfdfe
...
...
@@ -15633,6 +15633,9 @@ msgstr ""
msgid "customize"
msgstr ""
msgid "date must not be after 9999-12-31"
msgstr ""
msgid "day"
msgid_plural "days"
msgstr[0] ""
...
...
spec/models/milestone_spec.rb
View file @
424dfdfe
...
...
@@ -31,12 +31,28 @@ describe Milestone do
end
describe
'start_date'
do
it
'adds an error when start_date is greate
d
then due_date'
do
it
'adds an error when start_date is greate
r
then due_date'
do
milestone
=
build
(
:milestone
,
start_date:
Date
.
tomorrow
,
due_date:
Date
.
yesterday
)
expect
(
milestone
).
not_to
be_valid
expect
(
milestone
.
errors
[
:due_date
]).
to
include
(
"must be greater than start date"
)
end
it
'adds an error when start_date is greater than 9999-12-31'
do
milestone
=
build
(
:milestone
,
start_date:
Date
.
new
(
10000
,
1
,
1
))
expect
(
milestone
).
not_to
be_valid
expect
(
milestone
.
errors
[
:start_date
]).
to
include
(
"date must not be after 9999-12-31"
)
end
end
describe
'due_date'
do
it
'adds an error when due_date is greater than 9999-12-31'
do
milestone
=
build
(
:milestone
,
due_date:
Date
.
new
(
10000
,
1
,
1
))
expect
(
milestone
).
not_to
be_valid
expect
(
milestone
.
errors
[
:due_date
]).
to
include
(
"date must not be after 9999-12-31"
)
end
end
end
...
...
@@ -381,21 +397,6 @@ describe Milestone do
expect
(
milestone_ids
).
to
be_empty
end
end
context
'when there is a milestone with a date after 294276 AD'
,
:postgresql
do
before
do
past_milestone_project_1
.
update!
(
due_date:
Date
.
new
(
294277
,
1
,
1
))
end
it
'returns the next upcoming open milestone ID for each project and group'
do
expect
(
milestone_ids
).
to
contain_exactly
(
current_milestone_project_1
.
id
,
current_milestone_project_2
.
id
,
current_milestone_group_1
.
id
,
current_milestone_group_2
.
id
)
end
end
end
describe
'#to_reference'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment