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
247ae960
Commit
247ae960
authored
Apr 26, 2016
by
Long Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to assign labels and milestone to target project when moving issue
parent
df8fda60
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+10
-1
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+20
-0
No files found.
app/services/issues/move_service.rb
View file @
247ae960
...
...
@@ -41,7 +41,8 @@ module Issues
private
def
create_new_issue
new_params
=
{
id:
nil
,
iid:
nil
,
label_ids:
[],
milestone:
nil
,
new_params
=
{
id:
nil
,
iid:
nil
,
label_ids:
cloneable_label_ids
,
milestone:
cloneable_milestone_id
,
project:
@new_project
,
author:
@old_issue
.
author
,
description:
rewrite_content
(
@old_issue
.
description
)
}
...
...
@@ -49,6 +50,14 @@ module Issues
CreateService
.
new
(
@new_project
,
@current_user
,
new_params
).
execute
end
def
cloneable_label_ids
@new_project
.
labels
.
where
(
title:
@old_issue
.
labels
.
pluck
(
:title
)).
pluck
(
:id
)
end
def
cloneable_milestone_id
@new_project
.
milestones
.
find_by
(
title:
@old_issue
.
milestone
.
try
(
:title
))
end
def
rewrite_notes
@old_issue
.
notes
.
find_each
do
|
note
|
new_note
=
note
.
dup
...
...
spec/services/issues/move_service_spec.rb
View file @
247ae960
...
...
@@ -21,6 +21,15 @@ describe Issues::MoveService, services: true do
before
do
old_project
.
team
<<
[
user
,
:reporter
]
new_project
.
team
<<
[
user
,
:reporter
]
create
(
:milestone
,
project_id:
old_project
.
id
,
title:
'v1.0'
)
create
(
:milestone
,
project_id:
new_project
.
id
,
title:
'v1.0'
)
old_issue
.
labels
<<
create
(
:label
,
project_id:
old_project
.
id
,
title:
'label1'
)
old_issue
.
labels
<<
create
(
:label
,
project_id:
old_project
.
id
,
title:
'label2'
)
new_project
.
labels
<<
create
(
:label
,
title:
'label1'
)
new_project
.
labels
<<
create
(
:label
,
title:
'label2'
)
end
end
...
...
@@ -39,6 +48,17 @@ describe Issues::MoveService, services: true do
expect
(
new_issue
.
project
).
to
eq
new_project
end
it
'assigns milestone to new issue'
do
expect
(
new_issue
.
reload
.
milestone
.
title
).
to
eq
'v1.0'
end
it
'assign labels to new issue'
do
expected_label_titles
=
new_issue
.
reload
.
labels
.
map
(
&
:title
)
expect
(
expected_label_titles
).
to
include
'label1'
expect
(
expected_label_titles
).
to
include
'label2'
expect
(
expected_label_titles
.
size
).
to
eq
2
end
it
'rewrites issue title'
do
expect
(
new_issue
.
title
).
to
eq
title
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