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
23fee68b
Commit
23fee68b
authored
Aug 03, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename to update_start_and_due_dates for clarity
parent
dfc1a7c3
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
34 additions
and
36 deletions
+34
-36
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+2
-2
ee/app/services/ee/issues/update_service.rb
ee/app/services/ee/issues/update_service.rb
+1
-1
ee/app/services/ee/milestones/update_service.rb
ee/app/services/ee/milestones/update_service.rb
+1
-1
ee/app/services/epic_issues/create_service.rb
ee/app/services/epic_issues/create_service.rb
+1
-1
ee/app/services/epic_issues/destroy_service.rb
ee/app/services/epic_issues/destroy_service.rb
+1
-1
ee/app/services/epics/update_service.rb
ee/app/services/epics/update_service.rb
+1
-1
ee/spec/models/epic_spec.rb
ee/spec/models/epic_spec.rb
+14
-14
ee/spec/services/ee/issues/update_service_spec.rb
ee/spec/services/ee/issues/update_service_spec.rb
+4
-4
ee/spec/services/epic_issues/create_service_spec.rb
ee/spec/services/epic_issues/create_service_spec.rb
+2
-2
ee/spec/services/epic_issues/destroy_service_spec.rb
ee/spec/services/epic_issues/destroy_service_spec.rb
+2
-2
ee/spec/services/epics/update_service_spec.rb
ee/spec/services/epics/update_service_spec.rb
+4
-4
ee/spec/services/milestones/update_service_spec.rb
ee/spec/services/milestones/update_service_spec.rb
+1
-3
No files found.
ee/app/models/ee/epic.rb
View file @
23fee68b
...
...
@@ -82,7 +82,7 @@ module EE
::
Group
end
def
update_dates
(
epics
)
def
update_
start_and_due_
dates
(
epics
)
groups
=
epics
.
includes
(
:issues
).
group_by
do
|
epic
|
milestone_ids
=
epic
.
issues
.
map
(
&
:milestone_id
)
milestone_ids
.
compact!
...
...
@@ -142,7 +142,7 @@ module EE
# Needed to use EntityDateHelper#remaining_days_in_words
alias_attribute
(
:due_date
,
:end_date
)
def
update_dates
def
update_
start_and_due_
dates
results
=
Epics
::
DateSourcingMilestonesFinder
.
execute
(
id
)
self
.
start_date
=
start_date_is_fixed?
?
start_date_fixed
:
results
.
start_date
...
...
ee/app/services/ee/issues/update_service.rb
View file @
23fee68b
...
...
@@ -10,7 +10,7 @@ module EE
result
=
super
if
issue
.
previous_changes
.
include?
(
:milestone_id
)
&&
issue
.
epic
issue
.
epic
.
update_dates
issue
.
epic
.
update_
start_and_due_
dates
end
result
...
...
ee/app/services/ee/milestones/update_service.rb
View file @
23fee68b
...
...
@@ -10,7 +10,7 @@ module EE
super
if
dates_changed?
(
milestone
)
::
Epic
.
update_dates
(
::
Epic
.
update_
start_and_due_
dates
(
::
Epic
.
joins
(
:issues
).
where
(
issues:
{
milestone_id:
milestone
.
id
})
)
end
...
...
ee/app/services/epic_issues/create_service.rb
View file @
23fee68b
...
...
@@ -2,7 +2,7 @@ module EpicIssues
class
CreateService
<
IssuableLinks
::
CreateService
def
execute
result
=
super
issuable
.
update_dates
issuable
.
update_
start_and_due_
dates
result
end
...
...
ee/app/services/epic_issues/destroy_service.rb
View file @
23fee68b
...
...
@@ -2,7 +2,7 @@ module EpicIssues
class
DestroyService
<
IssuableLinks
::
DestroyService
def
execute
result
=
super
link
.
epic
.
update_dates
link
.
epic
.
update_
start_and_due_
dates
result
end
...
...
ee/app/services/epics/update_service.rb
View file @
23fee68b
...
...
@@ -8,7 +8,7 @@ module Epics
update
(
epic
)
if
(
params
.
keys
.
map
(
&
:to_sym
)
&
[
:start_date_fixed
,
:start_date_is_fixed
,
:due_date_fixed
,
:due_date_is_fixed
]).
present?
epic
.
update_dates
epic
.
update_
start_and_due_
dates
end
epic
...
...
ee/spec/models/epic_spec.rb
View file @
23fee68b
...
...
@@ -137,12 +137,12 @@ describe Epic do
end
end
describe
'#update_dates'
do
describe
'#update_
start_and_due_
dates'
do
context
'fixed date is set'
do
subject
{
create
(
:epic
,
:use_fixed_dates
,
start_date:
nil
,
end_date:
nil
)
}
it
'updates to fixed date'
do
subject
.
update_dates
subject
.
update_
start_and_due_
dates
expect
(
subject
.
start_date
).
to
eq
(
subject
.
start_date_fixed
)
expect
(
subject
.
due_date
).
to
eq
(
subject
.
due_date_fixed
)
...
...
@@ -177,7 +177,7 @@ describe Epic do
context
'complete start and due dates'
do
it
'updates to milestone dates'
do
subject
.
update_dates
subject
.
update_
start_and_due_
dates
expect
(
subject
.
start_date
).
to
eq
(
milestone1
.
start_date
)
expect
(
subject
.
due_date
).
to
eq
(
milestone2
.
due_date
)
...
...
@@ -201,7 +201,7 @@ describe Epic do
end
it
'updates to milestone dates'
do
subject
.
update_dates
subject
.
update_
start_and_due_
dates
expect
(
subject
.
start_date
).
to
eq
(
milestone1
.
start_date
)
expect
(
subject
.
due_date
).
to
eq
(
nil
)
...
...
@@ -225,7 +225,7 @@ describe Epic do
end
it
'updates to milestone dates'
do
subject
.
update_dates
subject
.
update_
start_and_due_
dates
expect
(
subject
.
start_date
).
to
eq
(
nil
)
expect
(
subject
.
due_date
).
to
eq
(
nil
)
...
...
@@ -239,7 +239,7 @@ describe Epic do
end
it
'updates to milestone dates'
do
subject
.
update_dates
subject
.
update_
start_and_due_
dates
expect
(
subject
.
start_date
).
to
eq
(
nil
)
expect
(
subject
.
start_date_sourcing_milestone_id
).
to
eq
(
nil
)
...
...
@@ -256,7 +256,7 @@ describe Epic do
context
'complete start and due dates'
do
it
'updates to milestone dates'
do
subject
.
update_dates
subject
.
update_
start_and_due_
dates
expect
(
subject
.
start_date
).
to
eq
(
milestone1
.
start_date
)
expect
(
subject
.
due_date
).
to
eq
(
milestone1
.
due_date
)
...
...
@@ -273,7 +273,7 @@ describe Epic do
end
it
'updates to milestone dates'
do
subject
.
update_dates
subject
.
update_
start_and_due_
dates
expect
(
subject
.
start_date
).
to
eq
(
milestone1
.
start_date
)
expect
(
subject
.
due_date
).
to
eq
(
nil
)
...
...
@@ -290,7 +290,7 @@ describe Epic do
end
it
'updates to milestone dates'
do
subject
.
update_dates
subject
.
update_
start_and_due_
dates
expect
(
subject
.
start_date
).
to
eq
(
nil
)
expect
(
subject
.
due_date
).
to
eq
(
nil
)
...
...
@@ -300,7 +300,7 @@ describe Epic do
end
end
describe
'.update_dates'
do
describe
'.update_
start_and_due_
dates'
do
def
link_epic_to_milestone
(
epic
,
milestone
)
create
(
:issue
,
epic:
epic
,
milestone:
milestone
)
end
...
...
@@ -322,7 +322,7 @@ describe Epic do
link_epic_to_milestone
(
epics
[
2
],
milestone1
)
link_epic_to_milestone
(
epics
[
2
],
milestone2
)
described_class
.
update_dates
(
described_class
.
where
(
id:
epics
.
map
(
&
:id
)))
described_class
.
update_
start_and_due_
dates
(
described_class
.
where
(
id:
epics
.
map
(
&
:id
)))
epics
.
each
(
&
:reload
)
...
...
@@ -350,7 +350,7 @@ describe Epic do
link_epic_to_milestone
(
epics
[
0
],
milestone
)
ActiveRecord
::
QueryRecorder
.
new
do
described_class
.
update_dates
(
described_class
.
where
(
id:
epics
.
map
(
&
:id
)))
described_class
.
update_
start_and_due_
dates
(
described_class
.
where
(
id:
epics
.
map
(
&
:id
)))
end
.
count
end
...
...
@@ -360,7 +360,7 @@ describe Epic do
epics
<<
create
(
:epic
)
expect
do
described_class
.
update_dates
(
described_class
.
where
(
id:
epics
.
map
(
&
:id
)))
described_class
.
update_
start_and_due_
dates
(
described_class
.
where
(
id:
epics
.
map
(
&
:id
)))
end
.
not_to
exceed_query_limit
(
control_count
)
end
...
...
@@ -371,7 +371,7 @@ describe Epic do
link_epic_to_milestone
(
epics
[
1
],
milestone
)
expect
do
described_class
.
update_dates
(
described_class
.
where
(
id:
epics
.
map
(
&
:id
)))
described_class
.
update_
start_and_due_
dates
(
described_class
.
where
(
id:
epics
.
map
(
&
:id
)))
end
.
not_to
exceed_query_limit
(
control_count
)
end
end
...
...
ee/spec/services/ee/issues/update_service_spec.rb
View file @
23fee68b
...
...
@@ -18,8 +18,8 @@ describe Issues::UpdateService do
context
'updating milestone'
do
let
(
:milestone
)
{
create
(
:milestone
)
}
it
'calls epic#update_dates'
do
expect
(
epic
).
to
receive
(
:update_dates
).
twice
it
'calls epic#update_
start_and_due_
dates'
do
expect
(
epic
).
to
receive
(
:update_
start_and_due_
dates
).
twice
update_issue
(
milestone:
milestone
)
update_issue
(
milestone_id:
nil
)
...
...
@@ -27,8 +27,8 @@ describe Issues::UpdateService do
end
context
'updating other fields'
do
it
'does not call epic#update_dates'
do
expect
(
epic
).
not_to
receive
(
:update_dates
)
it
'does not call epic#update_
start_and_due_
dates'
do
expect
(
epic
).
not_to
receive
(
:update_
start_and_due_
dates
)
update_issue
(
title:
'foo'
)
end
end
...
...
ee/spec/services/epic_issues/create_service_spec.rb
View file @
23fee68b
...
...
@@ -270,8 +270,8 @@ describe EpicIssues::CreateService do
end
context
'refresh epic dates'
do
it
'calls epic#update_dates'
do
expect
(
epic
).
to
receive
(
:update_dates
)
it
'calls epic#update_
start_and_due_
dates'
do
expect
(
epic
).
to
receive
(
:update_
start_and_due_
dates
)
assign_issue
([
valid_reference
])
end
...
...
ee/spec/services/epic_issues/destroy_service_spec.rb
View file @
23fee68b
...
...
@@ -77,8 +77,8 @@ describe EpicIssues::DestroyService do
end
context
'refresh epic dates'
do
it
'calls epic#update_dates'
do
expect
(
epic
).
to
receive
(
:update_dates
)
it
'calls epic#update_
start_and_due_
dates'
do
expect
(
epic
).
to
receive
(
:update_
start_and_due_
dates
)
subject
end
...
...
ee/spec/services/epics/update_service_spec.rb
View file @
23fee68b
...
...
@@ -130,16 +130,16 @@ describe Epics::UpdateService do
context
'refresh epic dates'
do
context
'date fields are updated'
do
it
'calls epic#update_dates'
do
expect
(
epic
).
to
receive
(
:update_dates
)
it
'calls epic#update_
start_and_due_
dates'
do
expect
(
epic
).
to
receive
(
:update_
start_and_due_
dates
)
update_epic
(
start_date_is_fixed:
true
,
start_date_fixed:
Date
.
today
)
end
end
context
'date fields are not updated'
do
it
'does not call epic#update_dates'
do
expect
(
epic
).
not_to
receive
(
:update_dates
)
it
'does not call epic#update_
start_and_due_
dates'
do
expect
(
epic
).
not_to
receive
(
:update_
start_and_due_
dates
)
update_epic
(
title:
'foo'
)
end
...
...
ee/spec/services/milestones/update_service_spec.rb
View file @
23fee68b
...
...
@@ -4,7 +4,7 @@ require 'spec_helper'
describe
Milestones
::
UpdateService
do
describe
'#execute'
do
context
'refresh related epic dates'
do
it
'
calls epic#update_
dates'
do
it
'
updates milestone sourced
dates'
do
project
=
create
(
:project
)
user
=
build
(
:user
)
milestone
=
create
(
:milestone
,
project:
project
)
...
...
@@ -14,8 +14,6 @@ describe Milestones::UpdateService do
described_class
.
new
(
project
,
user
,
{
due_date:
due_date
}).
execute
(
milestone
)
epic
.
reload
expect
(
epic
.
reload
).
to
have_attributes
(
start_date:
nil
,
start_date_sourcing_milestone:
nil
,
...
...
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