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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d0e4810a
Commit
d0e4810a
authored
Jan 08, 2020
by
Patrick Derichs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix missing write of weight events for moved issues
Add spec
parent
043ca1ee
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
10 deletions
+93
-10
app/services/issuable/clone/attributes_rewriter.rb
app/services/issuable/clone/attributes_rewriter.rb
+15
-0
ee/app/services/ee/issuable/common_system_notes_service.rb
ee/app/services/ee/issuable/common_system_notes_service.rb
+5
-3
ee/spec/features/issues/move_issue_resource_weight_events_spec.rb
...features/issues/move_issue_resource_weight_events_spec.rb
+56
-0
ee/spec/services/ee/issuable/common_system_notes_service_spec.rb
.../services/ee/issuable/common_system_notes_service_spec.rb
+2
-7
ee/spec/services/ee/issues/move_service_spec.rb
ee/spec/services/ee/issues/move_service_spec.rb
+15
-0
No files found.
app/services/issuable/clone/attributes_rewriter.rb
View file @
d0e4810a
...
...
@@ -18,6 +18,7 @@ module Issuable
new_entity
.
update
(
update_attributes
)
copy_resource_label_events
copy_resource_weight_events
end
private
...
...
@@ -60,6 +61,20 @@ module Issuable
end
end
def
copy_resource_weight_events
return
unless
original_entity
.
respond_to?
(
:resource_weight_events
)
original_entity
.
resource_weight_events
.
find_in_batches
do
|
batch
|
events
=
batch
.
map
do
|
event
|
event
.
attributes
.
except
(
'id'
,
'reference'
,
'reference_html'
)
.
merge
(
'issue_id'
=>
new_entity
.
id
)
end
Gitlab
::
Database
.
bulk_insert
(
ResourceWeightEvent
.
table_name
,
events
)
end
end
def
entity_key
new_entity
.
class
.
name
.
parameterize
(
'_'
).
foreign_key
end
...
...
ee/app/services/ee/issuable/common_system_notes_service.rb
View file @
d0e4810a
...
...
@@ -11,7 +11,7 @@ module EE
super
ActiveRecord
::
Base
.
no_touching
do
handle_weight_change
handle_weight_change
(
is_update
)
handle_date_change_note
if
is_update
end
end
...
...
@@ -28,11 +28,13 @@ module EE
end
end
def
handle_weight_change
def
handle_weight_change
(
is_update
)
return
unless
issuable
.
previous_changes
.
include?
(
'weight'
)
if
weight_changes_tracking_enabled?
EE
::
ResourceEvents
::
ChangeWeightService
.
new
([
issuable
],
current_user
,
Time
.
now
).
execute
# Only create a resource event here if is_update is true to exclude the move issue operation.
# ResourceEvents for moved issues are written within AttributesRewriter.
EE
::
ResourceEvents
::
ChangeWeightService
.
new
([
issuable
],
current_user
,
Time
.
now
).
execute
if
is_update
else
::
SystemNoteService
.
change_weight_note
(
issuable
,
issuable
.
project
,
current_user
)
end
...
...
ee/spec/features/issues/move_issue_resource_weight_events_spec.rb
0 → 100644
View file @
d0e4810a
# frozen_string_literal: true
require
'spec_helper'
# Regression test for https://gitlab.com/gitlab-org/gitlab/merge_requests/22461
describe
'Resource weight events'
,
:js
do
include
Spec
::
Support
::
Helpers
::
Features
::
NotesHelpers
describe
'move issue by quick action'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
weight:
nil
,
due_date:
Date
.
new
(
2016
,
8
,
28
))
}
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue
)
wait_for_all_requests
end
after
do
wait_for_requests
end
context
'when original issue has weight events'
do
let
(
:target_project
)
{
create
(
:project
,
:public
)
}
before
do
target_project
.
add_maintainer
(
user
)
add_note
(
"/weight 2"
)
wait_for_requests
add_note
(
"/weight 3
\n
/move
#{
target_project
.
full_path
}
"
)
end
it
"creates expected weight events on the moved issue"
do
expect
(
page
).
to
have_content
"Moved this issue to
#{
target_project
.
full_path
}
."
expect
(
issue
.
reload
).
to
be_closed
visit
project_issue_path
(
target_project
,
issue
)
wait_for_all_requests
expect
(
page
).
to
have_content
'changed weight to 2'
expect
(
page
).
to
have_content
'changed weight to 3'
visit
project_issue_path
(
project
,
issue
)
wait_for_all_requests
expect
(
page
).
to
have_content
'changed weight to 2'
expect
(
page
).
to
have_content
'changed weight to 3'
expect
(
page
).
to
have_content
'Closed'
end
end
end
end
ee/spec/services/ee/issuable/common_system_notes_service_spec.rb
View file @
d0e4810a
...
...
@@ -62,13 +62,8 @@ describe Issuable::CommonSystemNotesService do
stub_feature_flags
(
track_issue_weight_change_events:
true
)
end
it
'creates a resource weight event'
do
subject
event
=
issuable
.
resource_weight_events
.
last
expect
(
event
.
weight
).
to
eq
(
5
)
expect
(
event
.
user_id
).
to
eq
(
user
.
id
)
it
'does not create a resource weight event'
do
expect
{
subject
}.
not_to
change
{
ResourceWeightEvent
.
count
}
end
it
'does not create a system note'
do
...
...
ee/spec/services/ee/issues/move_service_spec.rb
View file @
d0e4810a
...
...
@@ -28,6 +28,21 @@ describe Issues::MoveService do
.
not_to
raise_error
# Sidekiq::Worker::EnqueueFromTransactionError
end
end
context
'resource weight events'
do
let!
(
:event1
)
{
create
(
:resource_weight_event
,
issue:
old_issue
,
weight:
1
)
}
let!
(
:event2
)
{
create
(
:resource_weight_event
,
issue:
old_issue
,
weight:
42
)
}
let!
(
:event3
)
{
create
(
:resource_weight_event
,
issue:
old_issue
,
weight:
5
)
}
let!
(
:another_old_issue
)
{
create
(
:issue
,
project:
new_project
,
author:
user
)
}
let!
(
:event4
)
{
create
(
:resource_weight_event
,
issue:
another_old_issue
,
weight:
2
)
}
it
'creates expected resource weight events'
do
new_issue
=
move_service
.
execute
(
old_issue
,
new_project
)
expect
(
new_issue
.
resource_weight_events
.
map
(
&
:weight
)).
to
contain_exactly
(
1
,
42
,
5
)
end
end
end
describe
'#rewrite_related_issues'
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