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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
f7844a11
Commit
f7844a11
authored
Apr 28, 2016
by
Long Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code refactor and fix broken spec
parent
d6d1daf4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+5
-3
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+13
-5
No files found.
app/services/issues/move_service.rb
View file @
f7844a11
...
@@ -42,7 +42,7 @@ module Issues
...
@@ -42,7 +42,7 @@ module Issues
def
create_new_issue
def
create_new_issue
new_params
=
{
id:
nil
,
iid:
nil
,
label_ids:
cloneable_label_ids
,
new_params
=
{
id:
nil
,
iid:
nil
,
label_ids:
cloneable_label_ids
,
milestone:
cloneable_milestone_id
,
milestone
_id
:
cloneable_milestone_id
,
project:
@new_project
,
author:
@old_issue
.
author
,
project:
@new_project
,
author:
@old_issue
.
author
,
description:
rewrite_content
(
@old_issue
.
description
)
}
description:
rewrite_content
(
@old_issue
.
description
)
}
...
@@ -51,11 +51,13 @@ module Issues
...
@@ -51,11 +51,13 @@ module Issues
end
end
def
cloneable_label_ids
def
cloneable_label_ids
@new_project
.
labels
.
where
(
title:
@old_issue
.
labels
.
pluck
(
:title
)).
pluck
(
:id
)
@new_project
.
labels
.
where
(
title:
@old_issue
.
labels
.
pluck
(
:title
)).
pluck
(
:id
)
end
end
def
cloneable_milestone_id
def
cloneable_milestone_id
@new_project
.
milestones
.
find_by
(
title:
@old_issue
.
milestone
.
try
(
:title
))
@new_project
.
milestones
.
find_by
(
title:
@old_issue
.
milestone
.
try
(
:title
)).
try
(
:id
)
end
end
def
rewrite_notes
def
rewrite_notes
...
...
spec/services/issues/move_service_spec.rb
View file @
f7844a11
...
@@ -7,7 +7,9 @@ describe Issues::MoveService, services: true do
...
@@ -7,7 +7,9 @@ describe Issues::MoveService, services: true do
let
(
:description
)
{
'Some issue description'
}
let
(
:description
)
{
'Some issue description'
}
let
(
:old_project
)
{
create
(
:project
)
}
let
(
:old_project
)
{
create
(
:project
)
}
let
(
:new_project
)
{
create
(
:project
)
}
let
(
:new_project
)
{
create
(
:project
)
}
let!
(
:milestone1
)
{
create
(
:milestone
,
project_id:
old_project
.
id
,
title:
'v9.0'
)
}
let!
(
:milestone1
)
do
create
(
:milestone
,
project_id:
old_project
.
id
,
title:
'v9.0'
)
end
let
(
:old_issue
)
do
let
(
:old_issue
)
do
create
(
:issue
,
title:
title
,
description:
description
,
create
(
:issue
,
title:
title
,
description:
description
,
...
@@ -23,10 +25,12 @@ describe Issues::MoveService, services: true do
...
@@ -23,10 +25,12 @@ describe Issues::MoveService, services: true do
old_project
.
team
<<
[
user
,
:reporter
]
old_project
.
team
<<
[
user
,
:reporter
]
new_project
.
team
<<
[
user
,
:reporter
]
new_project
.
team
<<
[
user
,
:reporter
]
create
(
:milestone
,
project_id:
new_project
.
id
,
title:
'v9.0'
)
[
'label1'
,
'label2'
].
each
do
|
label
|
old_issue
.
labels
<<
create
(
:label
,
old_issue
.
labels
<<
create
(
:label
,
project_id:
old_project
.
id
,
title:
'label1'
)
project_id:
old_project
.
id
,
old_issue
.
labels
<<
create
(
:label
,
project_id:
old_project
.
id
,
title:
'label2'
)
title:
label
)
end
new_project
.
labels
<<
create
(
:label
,
title:
'label1'
)
new_project
.
labels
<<
create
(
:label
,
title:
'label1'
)
new_project
.
labels
<<
create
(
:label
,
title:
'label2'
)
new_project
.
labels
<<
create
(
:label
,
title:
'label2'
)
...
@@ -35,6 +39,10 @@ describe Issues::MoveService, services: true do
...
@@ -35,6 +39,10 @@ describe Issues::MoveService, services: true do
describe
'#execute'
do
describe
'#execute'
do
shared_context
'issue move executed'
do
shared_context
'issue move executed'
do
let!
(
:milestone2
)
do
create
(
:milestone
,
project_id:
new_project
.
id
,
title:
'v9.0'
)
end
let!
(
:new_issue
)
{
move_service
.
execute
(
old_issue
,
new_project
)
}
let!
(
:new_issue
)
{
move_service
.
execute
(
old_issue
,
new_project
)
}
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