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
8732440f
Commit
8732440f
authored
Dec 15, 2020
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clone epic data when cloning issues
When using the clone quick action we should also clone epic data!
parent
f7eb59c3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
31 deletions
+135
-31
app/services/issues/clone_service.rb
app/services/issues/clone_service.rb
+2
-0
ee/app/services/ee/issues/clone_service.rb
ee/app/services/ee/issues/clone_service.rb
+26
-0
ee/changelogs/unreleased/9421-epics-should-clone.yml
ee/changelogs/unreleased/9421-epics-should-clone.yml
+5
-0
ee/spec/services/ee/issues/clone_service_spec.rb
ee/spec/services/ee/issues/clone_service_spec.rb
+102
-0
ee/spec/services/issues/clone_service_spec.rb
ee/spec/services/issues/clone_service_spec.rb
+0
-31
No files found.
app/services/issues/clone_service.rb
View file @
8732440f
...
...
@@ -88,3 +88,5 @@ module Issues
end
end
end
Issues
::
CloneService
.
prepend_if_ee
(
'EE::Issues::CloneService'
)
ee/app/services/ee/issues/clone_service.rb
0 → 100644
View file @
8732440f
# frozen_string_literal: true
module
EE
module
Issues
module
CloneService
extend
::
Gitlab
::
Utils
::
Override
override
:update_new_entity
def
update_new_entity
super
add_epic
end
private
def
add_epic
return
unless
epic
=
original_entity
.
epic
return
unless
can?
(
current_user
,
:update_epic
,
epic
.
group
)
updated
=
::
Issues
::
UpdateService
.
new
(
target_project
,
current_user
,
epic:
epic
).
execute
(
new_entity
)
::
Gitlab
::
UsageDataCounters
::
IssueActivityUniqueCounter
.
track_issue_changed_epic_action
(
author:
current_user
)
if
updated
end
end
end
end
ee/changelogs/unreleased/9421-epics-should-clone.yml
0 → 100644
View file @
8732440f
---
title
:
Clone epic data when cloning issues
merge_request
:
50097
author
:
type
:
added
ee/spec/services/ee/issues/clone_service_spec.rb
0 → 100644
View file @
8732440f
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Issues
::
CloneService
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:old_project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:new_project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:old_issue
,
reload:
true
)
{
create
(
:issue
,
project:
old_project
,
author:
user
)
}
let
(
:clone_service
)
{
described_class
.
new
(
old_project
,
user
)
}
subject
{
clone_service
.
execute
(
old_issue
,
new_project
)
}
before
do
group
.
add_reporter
(
user
)
end
describe
'#execute'
do
context
'group issue hooks'
do
let_it_be
(
:hook
)
{
create
(
:group_hook
,
group:
group
,
issues_events:
true
)
}
it
'executes group issue hooks'
do
allow_next_instance_of
(
WebHookService
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:execute
)
end
# Ideally, we'd test that `WebHookWorker.jobs.size` increased by 1,
# but since the entire spec run takes place in a transaction, we never
# actually get to the `after_commit` hook that queues these jobs.
expect
{
subject
}
.
not_to
raise_error
# Sidekiq::Worker::EnqueueFromTransactionError
end
end
context
'resource weight events'
do
let_it_be
(
:old_issue
)
{
create
(
:issue
,
project:
old_project
,
author:
user
,
weight:
5
)
}
let_it_be
(
:event1
)
{
create
(
:resource_weight_event
,
issue:
old_issue
,
weight:
1
)
}
let_it_be
(
:event2
)
{
create
(
:resource_weight_event
,
issue:
old_issue
,
weight:
42
)
}
let_it_be
(
:event3
)
{
create
(
:resource_weight_event
,
issue:
old_issue
,
weight:
5
)
}
let_it_be
(
:another_old_issue
)
{
create
(
:issue
,
project:
new_project
,
author:
user
)
}
let_it_be
(
:event4
)
{
create
(
:resource_weight_event
,
issue:
another_old_issue
,
weight:
2
)
}
it
'creates expected resource weight events'
do
expect
(
subject
.
resource_weight_events
.
map
(
&
:weight
)).
to
contain_exactly
(
1
,
42
,
5
)
end
end
context
'epics'
do
context
'issue assigned to epic'
do
let_it_be
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
before
do
stub_licensed_features
(
epics:
true
)
create
(
:epic_issue
,
issue:
old_issue
,
epic:
epic
)
end
it
'creates epic reference'
do
expect
(
subject
.
epic
).
to
eq
(
epic
)
end
it
'tracks usage data for changed epic action'
do
expect
(
Gitlab
::
UsageDataCounters
::
IssueActivityUniqueCounter
).
to
receive
(
:track_issue_changed_epic_action
).
with
(
author:
user
)
subject
end
context
'user can not update the epic'
do
before
do
group
.
group_member
(
user
).
destroy!
old_project
.
add_reporter
(
user
)
new_project
.
add_reporter
(
user
)
end
it
'ignores epic reference'
do
expect
(
subject
.
epic
).
to
be_nil
end
it
'does not send usage data for changed epic action'
do
expect
(
Gitlab
::
UsageDataCounters
::
IssueActivityUniqueCounter
).
not_to
receive
(
:track_issue_changed_epic_action
)
subject
end
end
context
'epic update fails'
do
it
'does not send usage data for changed epic action'
do
allow_next_instance_of
(
::
Issues
::
UpdateService
)
do
|
update_service
|
allow
(
update_service
).
to
receive
(
:execute
).
and_return
(
false
)
end
expect
(
Gitlab
::
UsageDataCounters
::
IssueActivityUniqueCounter
).
not_to
receive
(
:track_issue_changed_epic_action
)
subject
end
end
end
end
end
end
ee/spec/services/issues/clone_service_spec.rb
deleted
100644 → 0
View file @
f7eb59c3
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Issues
::
CloneService
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:author
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let_it_be
(
:sub_group_1
)
{
create
(
:group
,
:private
,
parent:
group
)
}
let_it_be
(
:old_project
)
{
create
(
:project
,
namespace:
group
)
}
let_it_be
(
:new_project
)
{
create
(
:project
,
namespace:
sub_group_1
)
}
let_it_be
(
:old_issue
)
{
create
(
:issue
,
project:
old_project
,
author:
author
,
epic:
epic
)
}
subject
(
:clone_service
)
do
described_class
.
new
(
old_project
,
user
)
end
let
(
:new_issue
)
{
clone_service
.
execute
(
old_issue
,
new_project
)
}
context
'user has enough permissions'
do
before
do
old_project
.
add_reporter
(
user
)
new_project
.
add_reporter
(
user
)
end
it
'does not copy epic'
do
expect
(
new_issue
.
epic
).
to
be_nil
end
end
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