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
5832102a
Commit
5832102a
authored
Dec 03, 2019
by
minghuan lei
Committed by
Heinrich Lee Yu
Dec 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Relate issues when being marked as duplicate
parent
dc7aadbf
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
39 deletions
+61
-39
app/services/issues/duplicate_service.rb
app/services/issues/duplicate_service.rb
+2
-0
changelogs/unreleased/3963-auto-related-duplicated-issues.yml
...gelogs/unreleased/3963-auto-related-duplicated-issues.yml
+5
-0
doc/user/project/quick_actions.md
doc/user/project/quick_actions.md
+1
-1
ee/app/services/ee/issues/duplicate_service.rb
ee/app/services/ee/issues/duplicate_service.rb
+23
-0
ee/spec/services/issues/duplicate_service_spec.rb
ee/spec/services/issues/duplicate_service_spec.rb
+27
-0
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+3
-2
spec/support/shared_examples/quick_actions/issue/duplicate_quick_action_shared_examples.rb
...k_actions/issue/duplicate_quick_action_shared_examples.rb
+0
-36
No files found.
app/services/issues/duplicate_service.rb
View file @
5832102a
...
@@ -25,3 +25,5 @@ module Issues
...
@@ -25,3 +25,5 @@ module Issues
end
end
end
end
end
end
Issues
::
DuplicateService
.
prepend_if_ee
(
'EE::Issues::DuplicateService'
)
changelogs/unreleased/3963-auto-related-duplicated-issues.yml
0 → 100644
View file @
5832102a
---
title
:
Relate issues when they are marked as duplicated
merge_request
:
20161
author
:
minghuan lei
type
:
added
doc/user/project/quick_actions.md
View file @
5832102a
...
@@ -60,7 +60,7 @@ The following quick actions are applicable to descriptions, discussions and thre
...
@@ -60,7 +60,7 @@ The following quick actions are applicable to descriptions, discussions and thre
|
`/remove_epic`
| ✓ | | | Remove from epic
**(ULTIMATE)**
|
|
`/remove_epic`
| ✓ | | | Remove from epic
**(ULTIMATE)**
|
|
`/promote`
| ✓ | | | Promote issue to epic
**(ULTIMATE)**
|
|
`/promote`
| ✓ | | | Promote issue to epic
**(ULTIMATE)**
|
|
`/confidential`
| ✓ | | | Make confidential |
|
`/confidential`
| ✓ | | | Make confidential |
|
`/duplicate <#issue>`
| ✓ | | | Mark this issue as a duplicate of another issue |
|
`/duplicate <#issue>`
| ✓ | | | Mark this issue as a duplicate of another issue
and relate them for
**(STARTER)**
|
|
`/create_merge_request <branch name>`
| ✓ | | | Create a new merge request starting from the current issue |
|
`/create_merge_request <branch name>`
| ✓ | | | Create a new merge request starting from the current issue |
|
`/relate #issue1 #issue2`
| ✓ | | | Mark issues as related
**(STARTER)**
|
|
`/relate #issue1 #issue2`
| ✓ | | | Mark issues as related
**(STARTER)**
|
|
`/move <path/to/project>`
| ✓ | | | Move this issue to another project |
|
`/move <path/to/project>`
| ✓ | | | Move this issue to another project |
...
...
ee/app/services/ee/issues/duplicate_service.rb
0 → 100644
View file @
5832102a
# frozen_string_literal: true
module
EE
module
Issues
module
DuplicateService
extend
::
Gitlab
::
Utils
::
Override
override
:execute
def
execute
(
duplicate_issue
,
canonical_issue
)
super
relate_two_issues
(
duplicate_issue
,
canonical_issue
)
end
private
def
relate_two_issues
(
duplicate_issue
,
canonical_issue
)
params
=
{
target_issuable:
canonical_issue
}
IssueLinks
::
CreateService
.
new
(
duplicate_issue
,
current_user
,
params
).
execute
end
end
end
end
ee/spec/services/issues/duplicate_service_spec.rb
0 → 100644
View file @
5832102a
# frozen_string_literal: true
require
'spec_helper'
describe
Issues
::
DuplicateService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:canonical_project
)
{
create
(
:project
)
}
let
(
:duplicate_project
)
{
create
(
:project
)
}
let
(
:canonical_issue
)
{
create
(
:issue
,
project:
canonical_project
)
}
let
(
:duplicate_issue
)
{
create
(
:issue
,
project:
duplicate_project
)
}
subject
{
described_class
.
new
(
duplicate_project
,
user
,
{})
}
describe
'#execute'
do
it
'relates the duplicate issues'
do
canonical_project
.
add_reporter
(
user
)
duplicate_project
.
add_reporter
(
user
)
subject
.
execute
(
duplicate_issue
,
canonical_issue
)
issue_link
=
IssueLink
.
last
expect
(
issue_link
.
source
).
to
eq
(
duplicate_issue
)
expect
(
issue_link
.
target
).
to
eq
(
canonical_issue
)
end
end
end
spec/services/issues/update_service_spec.rb
View file @
5832102a
...
@@ -689,8 +689,9 @@ describe Issues::UpdateService, :mailer do
...
@@ -689,8 +689,9 @@ describe Issues::UpdateService, :mailer do
context
'valid canonical_issue_id'
do
context
'valid canonical_issue_id'
do
it
'calls the duplicate service with both issues'
do
it
'calls the duplicate service with both issues'
do
expect_any_instance_of
(
Issues
::
DuplicateService
)
expect_next_instance_of
(
Issues
::
DuplicateService
)
do
|
service
|
.
to
receive
(
:execute
).
with
(
issue
,
canonical_issue
)
expect
(
service
).
to
receive
(
:execute
).
with
(
issue
,
canonical_issue
)
end
update_issue
(
canonical_issue_id:
canonical_issue
.
id
)
update_issue
(
canonical_issue_id:
canonical_issue
.
id
)
end
end
...
...
spec/support/shared_examples/quick_actions/issue/duplicate_quick_action_shared_examples.rb
deleted
100644 → 0
View file @
dc7aadbf
# frozen_string_literal: true
shared_examples
'duplicate quick action'
do
context
'mark issue as duplicate'
do
let
(
:original_issue
)
{
create
(
:issue
,
project:
project
)
}
context
'when the current user can update issues'
do
it
'does not create a note, and marks the issue as a duplicate'
do
add_note
(
"/duplicate #
#{
original_issue
.
to_reference
}
"
)
expect
(
page
).
not_to
have_content
"/duplicate
#{
original_issue
.
to_reference
}
"
expect
(
page
).
to
have_content
"marked this issue as a duplicate of
#{
original_issue
.
to_reference
}
"
expect
(
issue
.
reload
).
to
be_closed
end
end
context
'when the current user cannot update the issue'
do
let
(
:guest
)
{
create
(
:user
)
}
before
do
project
.
add_guest
(
guest
)
gitlab_sign_out
sign_in
(
guest
)
visit
project_issue_path
(
project
,
issue
)
end
it
'does not create a note, and does not mark the issue as a duplicate'
do
add_note
(
"/duplicate #
#{
original_issue
.
to_reference
}
"
)
expect
(
page
).
not_to
have_content
"marked this issue as a duplicate of
#{
original_issue
.
to_reference
}
"
expect
(
issue
.
reload
).
to
be_open
end
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