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
fe7f0a8a
Commit
fe7f0a8a
authored
Feb 02, 2021
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'remove-blocked-by-code' into 'master'
Remove blocked_by code See merge request gitlab-org/gitlab!52675
parents
8632edaa
7e96d71f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
22 deletions
+15
-22
app/models/issue_link.rb
app/models/issue_link.rb
+3
-1
ee/app/models/ee/issue_link.rb
ee/app/models/ee/issue_link.rb
+3
-8
ee/app/services/ee/issue_links/create_service.rb
ee/app/services/ee/issue_links/create_service.rb
+5
-7
ee/spec/controllers/projects/issue_links_controller_spec.rb
ee/spec/controllers/projects/issue_links_controller_spec.rb
+2
-2
ee/spec/models/issue_link_spec.rb
ee/spec/models/issue_link_spec.rb
+0
-1
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+1
-2
spec/models/issue_link_spec.rb
spec/models/issue_link_spec.rb
+1
-1
No files found.
app/models/issue_link.rb
View file @
fe7f0a8a
...
...
@@ -17,9 +17,11 @@ class IssueLink < ApplicationRecord
TYPE_RELATES_TO
=
'relates_to'
TYPE_BLOCKS
=
'blocks'
# we don't store is_blocked_by in the db but need it for displaying the relation
# from the target (used in IssueLink.inverse_link_type)
TYPE_IS_BLOCKED_BY
=
'is_blocked_by'
enum
link_type:
{
TYPE_RELATES_TO
=>
0
,
TYPE_BLOCKS
=>
1
,
TYPE_IS_BLOCKED_BY
=>
2
}
enum
link_type:
{
TYPE_RELATES_TO
=>
0
,
TYPE_BLOCKS
=>
1
}
def
self
.
inverse_link_type
(
type
)
type
...
...
ee/app/models/ee/issue_link.rb
View file @
fe7f0a8a
...
...
@@ -11,14 +11,9 @@ module EE
class_methods
do
def
inverse_link_type
(
type
)
case
type
when
::
IssueLink
::
TYPE_BLOCKS
::
IssueLink
::
TYPE_IS_BLOCKED_BY
when
::
IssueLink
::
TYPE_IS_BLOCKED_BY
::
IssueLink
::
TYPE_BLOCKS
else
type
end
return
::
IssueLink
::
TYPE_IS_BLOCKED_BY
if
type
==
::
IssueLink
::
TYPE_BLOCKS
type
end
def
blocked_issue_ids
(
issue_ids
)
...
...
ee/app/services/ee/issue_links/create_service.rb
View file @
fe7f0a8a
...
...
@@ -16,19 +16,17 @@ module EE
def
set_link_type
(
link
)
return
unless
params
[
:link_type
].
present?
link
.
link_type
=
params
[
:link_type
]
# `blocked_by` links are treated as `blocks` links where
# source and target is swapped. This is the first step toward
# removing `blocked_by` link type
# https://gitlab.com/gitlab-org/gitlab/-/issues/225919
if
link
.
is_blocked_by?
# `blocked_by` links are treated as `blocks` links where source and target is swapped.
if
params
[
:link_type
]
==
::
IssueLink
::
TYPE_IS_BLOCKED_BY
link
.
source
,
link
.
target
=
link
.
target
,
link
.
source
link
.
link_type
=
::
IssueLink
::
TYPE_BLOCKS
else
link
.
link_type
=
params
[
:link_type
]
end
end
def
link_type_available?
# `blocked_by` is allowed as a param and handled in set_link_type
return
true
unless
[
::
IssueLink
::
TYPE_BLOCKS
,
::
IssueLink
::
TYPE_IS_BLOCKED_BY
].
include?
(
params
[
:link_type
])
issuable
.
resource_parent
.
feature_available?
(
:blocked_issues
)
...
...
ee/spec/controllers/projects/issue_links_controller_spec.rb
View file @
fe7f0a8a
...
...
@@ -10,7 +10,7 @@ RSpec.describe Projects::IssueLinksController do
let_it_be
(
:issue2
)
{
create
(
:issue
,
project:
project
)
}
describe
'GET #index'
do
let_it_be
(
:issue_link
)
{
create
(
:issue_link
,
source:
issue1
,
target:
issue2
,
link_type:
'
is_blocked_by
'
)
}
let_it_be
(
:issue_link
)
{
create
(
:issue_link
,
source:
issue1
,
target:
issue2
,
link_type:
'
blocks
'
)
}
def
get_link
(
user
,
issue
)
sign_in
(
user
)
...
...
@@ -35,7 +35,7 @@ RSpec.describe Projects::IssueLinksController do
link
=
json_response
.
first
expect
(
link
[
'id'
]).
to
eq
(
issue2
.
id
)
expect
(
link
[
'link_type'
]).
to
eq
(
'
is_blocked_by
'
)
expect
(
link
[
'link_type'
]).
to
eq
(
'
blocks
'
)
end
end
...
...
ee/spec/models/issue_link_spec.rb
View file @
fe7f0a8a
...
...
@@ -81,7 +81,6 @@ RSpec.describe IssueLink do
it
'returns reverse type of link'
do
expect
(
described_class
.
inverse_link_type
(
'relates_to'
)).
to
eq
'relates_to'
expect
(
described_class
.
inverse_link_type
(
'blocks'
)).
to
eq
'is_blocked_by'
expect
(
described_class
.
inverse_link_type
(
'is_blocked_by'
)).
to
eq
'blocks'
end
end
...
...
ee/spec/models/issue_spec.rb
View file @
fe7f0a8a
...
...
@@ -696,9 +696,8 @@ RSpec.describe Issue do
where
(
:id
,
:issue_link_source_id
,
:issue_link_type_value
,
:expected
)
do
1
|
1
|
0
|
'relates_to'
1
|
1
|
1
|
'blocks'
1
|
2
|
3
|
'relates_to'
1
|
2
|
2
|
'relates_to'
1
|
2
|
1
|
'is_blocked_by'
1
|
2
|
2
|
'blocks'
end
with_them
do
...
...
spec/models/issue_link_spec.rb
View file @
fe7f0a8a
...
...
@@ -9,7 +9,7 @@ RSpec.describe IssueLink do
end
describe
'link_type'
do
it
{
is_expected
.
to
define_enum_for
(
:link_type
).
with_values
(
relates_to:
0
,
blocks:
1
,
is_blocked_by:
2
)
}
it
{
is_expected
.
to
define_enum_for
(
:link_type
).
with_values
(
relates_to:
0
,
blocks:
1
)
}
it
'provides the "related" as default link_type'
do
expect
(
create
(
:issue_link
).
link_type
).
to
eq
'relates_to'
...
...
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