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
175d2048
Commit
175d2048
authored
Jul 26, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent query of calculating milestone dates when fixed dates are not used
parent
5bec56da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
42 deletions
+64
-42
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+2
-2
ee/spec/models/epic_spec.rb
ee/spec/models/epic_spec.rb
+62
-40
No files found.
ee/app/models/ee/epic.rb
View file @
175d2048
...
...
@@ -123,12 +123,12 @@ module EE
# Earliest start date from issues' milestones
def
start_date_from_milestones
epic_issues
.
joins
(
issue: :milestone
).
minimum
(
'milestones.start_date'
)
start_date_is_fixed?
?
epic_issues
.
joins
(
issue: :milestone
).
minimum
(
'milestones.start_date'
)
:
start_date
end
# Latest end date from issues' milestones
def
due_date_from_milestones
epic_issues
.
joins
(
issue: :milestone
).
maximum
(
'milestones.due_date'
)
due_date_is_fixed?
?
epic_issues
.
joins
(
issue: :milestone
).
maximum
(
'milestones.due_date'
)
:
due_date
end
def
to_reference
(
from
=
nil
,
full:
false
)
...
...
ee/spec/models/epic_spec.rb
View file @
175d2048
...
...
@@ -98,56 +98,78 @@ describe Epic do
end
describe
'#start_date_from_milestones'
do
subject
{
create
(
:epic
)
}
let
(
:date
)
{
Date
.
new
(
2017
,
3
,
4
)
}
context
'fixed date'
do
subject
{
create
(
:epic
,
:use_fixed_dates
)
}
let
(
:date
)
{
Date
.
new
(
2017
,
3
,
4
)
}
before
do
milestone1
=
create
(
:milestone
,
start_date:
date
,
due_date:
date
+
10
.
days
)
epic_issue1
=
create
(
:epic_issue
,
epic:
subject
)
epic_issue1
.
issue
.
update
(
milestone:
milestone1
)
milestone2
=
create
(
:milestone
,
start_date:
date
+
5
.
days
,
due_date:
date
+
15
.
days
)
epic_issue2
=
create
(
:epic_issue
,
epic:
subject
)
epic_issue2
.
issue
.
update
(
milestone:
milestone2
)
before
do
milestone1
=
create
(
:milestone
,
start_date:
date
,
due_date:
date
+
10
.
days
)
epic_issue1
=
create
(
:epic_issue
,
epic:
subject
)
epic_issue1
.
issue
.
update
(
milestone:
milestone1
)
milestone2
=
create
(
:milestone
,
start_date:
date
+
5
.
days
,
due_date:
date
+
15
.
days
)
epic_issue2
=
create
(
:epic_issue
,
epic:
subject
)
epic_issue2
.
issue
.
update
(
milestone:
milestone2
)
end
it
'returns earliest start date from issue milestones'
do
expect
(
subject
.
start_date_from_milestones
).
to
eq
(
date
)
end
end
it
'returns earliest start date from issue milestones'
do
expect
(
subject
.
start_date_from_milestones
).
to
eq
(
date
)
context
'milestone date'
do
subject
{
create
(
:epic
,
start_date:
date
)
}
let
(
:date
)
{
Date
.
new
(
2017
,
3
,
4
)
}
it
'returns start_date'
do
expect
(
subject
.
start_date_from_milestones
).
to
eq
(
date
)
end
end
end
describe
'#due_date_from_milestones'
do
subject
{
create
(
:epic
)
}
let
(
:date
)
{
Date
.
new
(
2017
,
3
,
4
)
}
context
'fixed date'
do
subject
{
create
(
:epic
,
:use_fixed_dates
)
}
let
(
:date
)
{
Date
.
new
(
2017
,
3
,
4
)
}
before
do
milestone1
=
create
(
:milestone
,
start_date:
date
-
30
.
days
,
due_date:
date
-
20
.
days
)
epic_issue1
=
create
(
:epic_issue
,
epic:
subject
)
epic_issue1
.
issue
.
update
(
milestone:
milestone1
)
milestone2
=
create
(
:milestone
,
start_date:
date
-
10
.
days
,
due_date:
date
)
epic_issue2
=
create
(
:epic_issue
,
epic:
subject
)
epic_issue2
.
issue
.
update
(
milestone:
milestone2
)
before
do
milestone1
=
create
(
:milestone
,
start_date:
date
-
30
.
days
,
due_date:
date
-
20
.
days
)
epic_issue1
=
create
(
:epic_issue
,
epic:
subject
)
epic_issue1
.
issue
.
update
(
milestone:
milestone1
)
milestone2
=
create
(
:milestone
,
start_date:
date
-
10
.
days
,
due_date:
date
)
epic_issue2
=
create
(
:epic_issue
,
epic:
subject
)
epic_issue2
.
issue
.
update
(
milestone:
milestone2
)
end
it
'returns latest due date from issue milestones'
do
expect
(
subject
.
due_date_from_milestones
).
to
eq
(
date
)
end
end
it
'returns latest due date from issue milestones'
do
expect
(
subject
.
due_date_from_milestones
).
to
eq
(
date
)
context
'milestone date'
do
subject
{
create
(
:epic
,
due_date:
date
)
}
let
(
:date
)
{
Date
.
new
(
2017
,
3
,
4
)
}
it
'returns due_date'
do
expect
(
subject
.
due_date_from_milestones
).
to
eq
(
date
)
end
end
end
...
...
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