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
95865da5
Commit
95865da5
authored
Jan 10, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug where award emojis would be lost when moving issues between projects
Closes #33423
parent
3576d59a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+11
-5
changelogs/unreleased/sh-fix-award-emoji-move-issues.yml
changelogs/unreleased/sh-fix-award-emoji-move-issues.yml
+5
-0
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+9
-3
No files found.
app/services/issues/move_service.rb
View file @
95865da5
...
...
@@ -24,7 +24,7 @@ module Issues
@new_issue
=
create_new_issue
rewrite_notes
rewrite_award_emoji
rewrite_
issue_
award_emoji
add_note_moved_from
# Old issue tasks
...
...
@@ -76,7 +76,7 @@ module Issues
end
def
rewrite_notes
@old_issue
.
notes
.
find_each
do
|
note
|
@old_issue
.
notes
_with_associations
.
find_each
do
|
note
|
new_note
=
note
.
dup
new_params
=
{
project:
@new_project
,
noteable:
@new_issue
,
note:
rewrite_content
(
new_note
.
note
),
...
...
@@ -84,13 +84,19 @@ module Issues
updated_at:
note
.
updated_at
}
new_note
.
update
(
new_params
)
rewrite_award_emoji
(
note
,
new_note
)
end
end
def
rewrite_award_emoji
@old_issue
.
award_emoji
.
each
do
|
award
|
def
rewrite_issue_award_emoji
rewrite_award_emoji
(
@old_issue
,
@new_issue
)
end
def
rewrite_award_emoji
(
old_awardable
,
new_awardable
)
old_awardable
.
award_emoji
.
each
do
|
award
|
new_award
=
award
.
dup
new_award
.
awardable
=
@new_issu
e
new_award
.
awardable
=
new_awardabl
e
new_award
.
save
end
end
...
...
changelogs/unreleased/sh-fix-award-emoji-move-issues.yml
0 → 100644
View file @
95865da5
---
title
:
Fix bug where award emojis would be lost when moving issues between projects
merge_request
:
author
:
type
:
fixed
spec/services/issues/move_service_spec.rb
View file @
95865da5
...
...
@@ -179,13 +179,15 @@ describe Issues::MoveService do
{
system:
true
,
note:
'Some system note'
},
{
system:
false
,
note:
'Some comment 2'
}]
end
let
(
:award_names
)
{
%w(thumbsup thumbsdown facepalm)
}
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
|
create
(
:note
,
note_params
.
merge
(
note
))
notes_params
.
each_with_index
do
|
note
,
index
|
new_note
=
create
(
:note
,
note_params
.
merge
(
note
))
award_emoji_params
=
{
awardable:
new_note
,
name:
award_names
[
index
]
}
create
(
:award_emoji
,
award_emoji_params
)
end
end
...
...
@@ -199,6 +201,10 @@ describe Issues::MoveService do
expect
(
all_notes
.
pluck
(
:note
).
first
(
3
)).
to
eq
notes_contents
end
it
'creates new emojis for the new notes'
do
expect
(
all_notes
.
map
(
&
:award_emoji
).
to_a
.
flatten
.
map
(
&
:name
)).
to
eq
award_names
end
it
'adds a system note about move after rewritten notes'
do
expect
(
system_notes
.
last
.
note
).
to
match
/^moved from/
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