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
03034a09
Commit
03034a09
authored
Aug 06, 2020
by
Alan (Maciej) Paruszewski
Committed by
James Lopez
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Vulnerability::IssueLinks when moving Issues to new Project
parent
19368f19
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
0 deletions
+34
-0
ee/app/models/vulnerabilities/issue_link.rb
ee/app/models/vulnerabilities/issue_link.rb
+1
-0
ee/app/services/ee/issues/move_service.rb
ee/app/services/ee/issues/move_service.rb
+6
-0
ee/changelogs/unreleased/233839-update-vulnerability-issue-links-when-moving-issue.yml
...39-update-vulnerability-issue-links-when-moving-issue.yml
+5
-0
ee/spec/models/vulnerabilities/issue_link_spec.rb
ee/spec/models/vulnerabilities/issue_link_spec.rb
+10
-0
ee/spec/services/ee/issues/move_service_spec.rb
ee/spec/services/ee/issues/move_service_spec.rb
+12
-0
No files found.
ee/app/models/vulnerabilities/issue_link.rb
View file @
03034a09
...
...
@@ -19,5 +19,6 @@ module Vulnerabilities
if: :created?
scope
:by_link_type
,
->
(
link_type
)
{
link_type
?
where
(
link_type:
link_type
.
downcase
)
:
all
}
scope
:for_issue
,
->
(
issue
)
{
where
(
issue_id:
issue
)
}
end
end
ee/app/services/ee/issues/move_service.rb
View file @
03034a09
...
...
@@ -9,6 +9,7 @@ module EE
def
update_old_entity
rewrite_epic_issue
rewrite_related_issues
rewrite_related_vulnerability_issues
super
end
...
...
@@ -29,6 +30,11 @@ module EE
target_issue_links
=
IssueLink
.
for_target_issue
(
original_entity
)
target_issue_links
.
update_all
(
target_id:
new_entity
.
id
)
end
def
rewrite_related_vulnerability_issues
issue_links
=
Vulnerabilities
::
IssueLink
.
for_issue
(
original_entity
)
issue_links
.
update_all
(
issue_id:
new_entity
.
id
)
end
end
end
end
ee/changelogs/unreleased/233839-update-vulnerability-issue-links-when-moving-issue.yml
0 → 100644
View file @
03034a09
---
title
:
Update Vulnerability::IssueLinks when moving Issues to new Project
merge_request
:
38765
author
:
type
:
fixed
ee/spec/models/vulnerabilities/issue_link_spec.rb
View file @
03034a09
...
...
@@ -103,4 +103,14 @@ RSpec.describe Vulnerabilities::IssueLink do
it
{
is_expected
.
to
match_array
([
related_issue_link
])
}
end
end
describe
'.for_issue'
do
let_it_be
(
:issue
)
{
create
(
:issue
)
}
let_it_be
(
:created_issue_link
)
{
create
(
:vulnerabilities_issue_link
,
:created
,
issue:
issue
)
}
let_it_be
(
:related_issue_link
)
{
create
(
:vulnerabilities_issue_link
,
:related
,
issue:
issue
)
}
subject
{
described_class
.
for_issue
(
issue
).
to_a
}
it
{
is_expected
.
to
match_array
([
created_issue_link
,
related_issue_link
])
}
end
end
ee/spec/services/ee/issues/move_service_spec.rb
View file @
03034a09
...
...
@@ -86,6 +86,18 @@ RSpec.describe Issues::MoveService do
end
end
describe
'#rewrite_related_vulnerability_issues'
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:vulnerabilities_issue_link
)
{
create
(
:vulnerabilities_issue_link
,
issue:
old_issue
)
}
it
'updates all vulnerability issue links with new issue'
do
new_issue
=
move_service
.
execute
(
old_issue
,
new_project
)
expect
(
vulnerabilities_issue_link
.
reload
.
issue
).
to
eq
(
new_issue
)
end
end
describe
'#rewrite_epic_issue'
do
context
'issue assigned to epic'
do
let!
(
:epic_issue
)
{
create
(
:epic_issue
,
issue:
old_issue
)
}
...
...
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