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
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
...
@@ -79,28 +79,30 @@ module Issues
SystemNoteService
.
noteable_moved
(
:to
,
@issue_old
,
@project_old
,
@issue_new
,
@current_user
)
SystemNoteService
.
noteable_moved
(
:to
,
@issue_old
,
@project_old
,
@issue_new
,
@current_user
)
end
end
def
rewrite_references
(
mention
able
)
def
rewrite_references
(
note
able
)
references
=
mention
able
.
all_references
references
=
note
able
.
all_references
new_content
=
mentionable_content
(
mention
able
).
dup
new_content
=
noteable_content
(
note
able
).
dup
cross_project_
ref
s
=
[
:issues
,
:merge_requests
,
:milestones
,
cross_project_
mentionable
s
=
[
:issues
,
:merge_requests
,
:milestones
,
:snippets
,
:commits
,
:commit_ranges
]
:snippets
,
:commits
,
:commit_ranges
]
cross_project_
ref
s
.
each
do
|
type
|
cross_project_
mentionable
s
.
each
do
|
type
|
references
.
public_send
(
type
).
each
do
|
mention
ed
|
references
.
public_send
(
type
).
each
do
|
mention
able
|
new_content
.
gsub!
(
mention
ed
.
to_reference
,
new_content
.
gsub!
(
mention
able
.
to_reference
,
mention
ed
.
to_reference
(
@project_new
))
mention
able
.
to_reference
(
@project_new
))
end
end
end
end
new_content
new_content
end
end
def
mentionable_content
(
mentionable
)
def
noteable_content
(
noteable
)
case
mentionable
case
noteable
when
Issue
then
mentionable
.
description
when
Issue
when
Note
then
mentionable
.
note
noteable
.
description
when
Note
noteable
.
note
else
else
raise
'Unexpected
mention
able while moving an issue'
raise
'Unexpected
note
able while moving an issue'
end
end
end
end
end
end
...
...
spec/services/issues/move_service_spec.rb
View file @
efd82517
...
@@ -101,6 +101,8 @@ describe Issues::MoveService, services: true do
...
@@ -101,6 +101,8 @@ describe Issues::MoveService, services: true do
{
system:
false
,
note:
'Some comment 2'
}]
{
system:
false
,
note:
'Some comment 2'
}]
end
end
let
(
:notes_contents
)
{
notes_params
.
map
{
|
n
|
n
[
:note
]
}
}
before
do
before
do
note_params
=
{
noteable:
old_issue
,
project:
old_project
,
author:
author
}
note_params
=
{
noteable:
old_issue
,
project:
old_project
,
author:
author
}
notes_params
.
each
do
|
note
|
notes_params
.
each
do
|
note
|
...
@@ -115,8 +117,7 @@ describe Issues::MoveService, services: true do
...
@@ -115,8 +117,7 @@ describe Issues::MoveService, services: true do
let
(
:user_notes
)
{
all_notes
.
user
}
let
(
:user_notes
)
{
all_notes
.
user
}
it
'rewrites existing notes in valid order'
do
it
'rewrites existing notes in valid order'
do
expect
(
all_notes
.
pluck
(
:note
).
first
(
3
))
expect
(
all_notes
.
pluck
(
:note
).
first
(
3
)).
to
eq
notes_contents
.
to
eq
notes_params
.
map
{
|
n
|
n
[
:note
]
}
end
end
it
'adds a system note about move after rewritten notes'
do
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