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
Léo-Paul Géneau
gitlab-ce
Commits
efd82517
Commit
efd82517
authored
Feb 24, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring of issue move service and specs
parent
c2d4060f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
17 deletions
+20
-17
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+17
-15
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+3
-2
No files found.
app/services/issues/move_service.rb
View file @
efd82517
...
...
@@ -79,28 +79,30 @@ module Issues
SystemNoteService
.
noteable_moved
(
:to
,
@issue_old
,
@project_old
,
@issue_new
,
@current_user
)
end
def
rewrite_references
(
mention
able
)
references
=
mention
able
.
all_references
new_content
=
mentionable_content
(
mention
able
).
dup
cross_project_
ref
s
=
[
:issues
,
:merge_requests
,
:milestones
,
:snippets
,
:commits
,
:commit_ranges
]
cross_project_
ref
s
.
each
do
|
type
|
references
.
public_send
(
type
).
each
do
|
mention
ed
|
new_content
.
gsub!
(
mention
ed
.
to_reference
,
mention
ed
.
to_reference
(
@project_new
))
def
rewrite_references
(
note
able
)
references
=
note
able
.
all_references
new_content
=
noteable_content
(
note
able
).
dup
cross_project_
mentionable
s
=
[
:issues
,
:merge_requests
,
:milestones
,
:snippets
,
:commits
,
:commit_ranges
]
cross_project_
mentionable
s
.
each
do
|
type
|
references
.
public_send
(
type
).
each
do
|
mention
able
|
new_content
.
gsub!
(
mention
able
.
to_reference
,
mention
able
.
to_reference
(
@project_new
))
end
end
new_content
end
def
mentionable_content
(
mentionable
)
case
mentionable
when
Issue
then
mentionable
.
description
when
Note
then
mentionable
.
note
def
noteable_content
(
noteable
)
case
noteable
when
Issue
noteable
.
description
when
Note
noteable
.
note
else
raise
'Unexpected
mention
able while moving an issue'
raise
'Unexpected
note
able while moving an issue'
end
end
end
...
...
spec/services/issues/move_service_spec.rb
View file @
efd82517
...
...
@@ -101,6 +101,8 @@ describe Issues::MoveService, services: true do
{
system:
false
,
note:
'Some comment 2'
}]
end
let
(
:notes_contents
)
{
notes_params
.
map
{
|
n
|
n
[
:note
]
}
}
before
do
note_params
=
{
noteable:
old_issue
,
project:
old_project
,
author:
author
}
notes_params
.
each
do
|
note
|
...
...
@@ -115,8 +117,7 @@ describe Issues::MoveService, services: true do
let
(
:user_notes
)
{
all_notes
.
user
}
it
'rewrites existing notes in valid order'
do
expect
(
all_notes
.
pluck
(
:note
).
first
(
3
))
.
to
eq
notes_params
.
map
{
|
n
|
n
[
:note
]
}
expect
(
all_notes
.
pluck
(
:note
).
first
(
3
)).
to
eq
notes_contents
end
it
'adds a system note about move after rewritten 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