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
0f7cb967
Commit
0f7cb967
authored
Jul 10, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix milestones destroy service
parent
31ada792
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
app/services/milestones/destroy_service.rb
app/services/milestones/destroy_service.rb
+4
-2
spec/services/milestones/destroy_service_spec.rb
spec/services/milestones/destroy_service_spec.rb
+51
-0
No files found.
app/services/milestones/destroy_service.rb
View file @
0f7cb967
module
Milestones
class
DestroyService
<
Milestones
::
BaseService
def
execute
(
milestone
)
return
unless
milestone
.
is_project_milestone?
Milestone
.
transaction
do
update_params
=
{
milestone:
nil
}
milestone
.
issues
.
each
do
|
issue
|
Issues
::
UpdateService
.
new
(
p
rojec
t
,
current_user
,
update_params
).
execute
(
issue
)
Issues
::
UpdateService
.
new
(
p
aren
t
,
current_user
,
update_params
).
execute
(
issue
)
end
milestone
.
merge_requests
.
each
do
|
merge_request
|
MergeRequests
::
UpdateService
.
new
(
p
rojec
t
,
current_user
,
update_params
).
execute
(
merge_request
)
MergeRequests
::
UpdateService
.
new
(
p
aren
t
,
current_user
,
update_params
).
execute
(
merge_request
)
end
event_service
.
destroy_milestone
(
milestone
,
current_user
)
...
...
spec/services/milestones/destroy_service_spec.rb
0 → 100644
View file @
0f7cb967
require
'spec_helper'
describe
Milestones
::
DestroyService
,
services:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:milestone
)
{
create
(
:milestone
,
title:
'Milestone v1.0'
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
milestone:
milestone
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
milestone:
milestone
)
}
before
do
project
.
team
<<
[
user
,
:master
]
end
def
service
described_class
.
new
(
project
,
user
,
{})
end
describe
'#execute'
do
it
'deletes milestone'
do
service
.
execute
(
milestone
)
expect
{
milestone
.
reload
}.
to
raise_error
ActiveRecord
::
RecordNotFound
end
it
'deletes milestone id from issuables'
do
service
.
execute
(
milestone
)
expect
(
issue
.
reload
.
milestone
).
to
be_nil
expect
(
merge_request
.
reload
.
milestone
).
to
be_nil
end
context
'group milestones'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:group_milestone
)
{
create
(
:milestone
,
group:
group
)
}
before
do
project
.
update
(
namespace:
group
)
group
.
add_developer
(
user
)
end
it
{
expect
(
service
.
execute
(
group_milestone
)).
to
be_nil
}
it
'does not update milestone issuables'
do
expect
(
MergeRequests
::
UpdateService
).
not_to
receive
(
:new
)
expect
(
Issues
::
UpdateService
).
not_to
receive
(
:new
)
service
.
execute
(
group_milestone
)
end
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