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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
fbb5a8b0
Commit
fbb5a8b0
authored
Feb 24, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a new issue create service when moving an issue
parent
57eb3954
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+24
-5
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+5
-0
No files found.
app/services/issues/move_service.rb
View file @
fbb5a8b0
...
...
@@ -4,7 +4,7 @@ module Issues
super
(
project
,
current_user
,
params
)
@issue_old
=
issue
@issue_new
=
@issue_old
.
dup
@issue_new
=
nil
@project_old
=
@project
@project_new
=
Project
.
find
(
new_project_id
)
if
new_project_id
end
...
...
@@ -42,8 +42,18 @@ module Issues
end
def
open_new_issue
new_description
=
rewrite_references
(
@issue_old
,
@issue_old
.
description
)
@issue_new
.
update
(
project:
@project_new
,
description:
new_description
)
create_service
=
CreateService
.
new
(
@project_new
,
current_user
,
new_issue_params
)
@issue_new
=
create_service
.
execute
end
def
new_issue_params
new_params
=
{
id:
nil
,
iid:
nil
,
milestone_id:
nil
,
label_ids:
[],
project_id:
@project_new
.
id
,
author_id:
@issue_old
.
author_id
,
description:
rewrite_references
(
@issue_old
),
updated_by_id:
current_user
.
id
}
params
.
merge
(
new_params
)
end
def
rewrite_notes
...
...
@@ -68,9 +78,9 @@ module Issues
SystemNoteService
.
noteable_moved
(
:to
,
@issue_old
,
@project_old
,
@issue_new
,
@current_user
)
end
def
rewrite_references
(
mentionable
,
text
)
new_content
=
text
.
dup
def
rewrite_references
(
mentionable
)
references
=
mentionable
.
all_references
new_content
=
mentionable_content
(
mentionable
).
dup
[
:issues
,
:merge_requests
,
:milestones
].
each
do
|
type
|
references
.
public_send
(
type
).
each
do
|
mentioned
|
...
...
@@ -81,5 +91,14 @@ module Issues
new_content
end
def
mentionable_content
(
mentionable
)
case
mentionable
when
Issue
then
mentionable
.
description
when
Note
then
mentionable
.
note
else
raise
'Unexpected mentionable while moving an issue'
end
end
end
end
spec/services/issues/move_service_spec.rb
View file @
fbb5a8b0
...
...
@@ -68,6 +68,11 @@ describe Issues::MoveService, services: true do
it
'persists new issue'
do
expect
(
new_issue
.
persisted?
).
to
be
true
end
it
'persist all changes'
do
expect
(
old_issue
.
changed?
).
to
be
false
expect
(
new_issue
.
changed?
).
to
be
false
end
end
context
'issue with notes'
do
...
...
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