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
415dbc24
Commit
415dbc24
authored
Feb 24, 2020
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix displaying blocked issues on the board
- add state argument to IssueLink.blocked_issue_ids
parent
d5b52019
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
5 deletions
+31
-5
changelogs/unreleased/207087-blocked-status-issue.yml
changelogs/unreleased/207087-blocked-status-issue.yml
+5
-0
ee/app/models/issue_link.rb
ee/app/models/issue_link.rb
+17
-2
ee/spec/controllers/boards/issues_controller_spec.rb
ee/spec/controllers/boards/issues_controller_spec.rb
+7
-2
ee/spec/models/issue_link_spec.rb
ee/spec/models/issue_link_spec.rb
+2
-1
No files found.
changelogs/unreleased/207087-blocked-status-issue.yml
0 → 100644
View file @
415dbc24
---
title
:
Don't show issue as blocked on the issue board if blocking issue is closed
merge_request
:
25817
author
:
type
:
fixed
ee/app/models/issue_link.rb
View file @
415dbc24
...
...
@@ -33,13 +33,28 @@ class IssueLink < ApplicationRecord
def
self
.
blocked_issue_ids
(
issue_ids
)
from_union
([
IssueLink
.
select
(
'target_id as issue_id'
).
where
(
link_type:
IssueLink
::
TYPE_BLOCKS
).
where
(
target_id:
issue_ids
),
IssueLink
.
select
(
'source_id as issue_id'
).
where
(
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
).
where
(
source_id:
issue_ids
)
blocked_issues
(
issue_ids
,
IssueLink
::
TYPE_BLOCKS
),
blocked_issues
(
issue_ids
,
IssueLink
::
TYPE_IS_BLOCKED_BY
)
]).
pluck
(
:issue_id
)
end
private
def
self
.
blocked_issues
(
issue_ids
,
link_type
)
if
link_type
==
IssueLink
::
TYPE_BLOCKS
blocked_key
=
:target_id
blocking_key
=
:source_id
else
blocked_key
=
:source_id
blocking_key
=
:target_id
end
select
(
"
#{
blocked_key
}
as issue_id"
)
.
where
(
link_type:
link_type
).
where
(
blocked_key
=>
issue_ids
)
.
joins
(
"INNER JOIN issues ON issues.id = issue_links.
#{
blocking_key
}
"
)
.
where
(
'issues.state_id'
=>
Issuable
::
STATE_ID_MAP
[
:opened
])
end
def
check_self_relation
return
unless
source
&&
target
...
...
ee/spec/controllers/boards/issues_controller_spec.rb
View file @
415dbc24
...
...
@@ -50,21 +50,26 @@ describe Boards::IssuesController do
expect
(
development
.
issues
.
map
(
&
:relative_position
)).
not_to
include
(
nil
)
end
it
'returns blocked status for each issue'
do
it
'returns blocked status for each issue
where the blocking issue is still opened
'
do
issue1
=
create
(
:labeled_issue
,
project:
project_1
,
labels:
[
development
],
relative_position:
1
)
issue2
=
create
(
:labeled_issue
,
project:
project_1
,
labels:
[
development
],
relative_position:
2
)
issue3
=
create
(
:labeled_issue
,
project:
project_1
,
labels:
[
development
],
relative_position:
3
)
issue4
=
create
(
:labeled_issue
,
project:
project_1
,
labels:
[
development
],
relative_position:
4
)
closed_issue
=
create
(
:issue
,
:closed
,
project:
project_1
)
create
(
:issue_link
,
source:
issue1
,
target:
issue2
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
create
(
:issue_link
,
source:
issue2
,
target:
issue3
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue4
,
target:
closed_issue
,
link_type:
IssueLink
::
TYPE_IS_BLOCKED_BY
)
list_issues
user:
user
,
board:
board
,
list:
list2
expect
(
response
).
to
match_response_schema
(
'entities/issue_boards'
)
issues
=
json_response
[
'issues'
]
expect
(
issues
.
length
).
to
eq
3
expect
(
issues
.
length
).
to
eq
4
expect
(
issues
[
0
][
'blocked'
]).
to
be_truthy
expect
(
issues
[
1
][
'blocked'
]).
to
be_falsey
expect
(
issues
[
2
][
'blocked'
]).
to
be_truthy
expect
(
issues
[
3
][
'blocked'
]).
to
be_falsey
end
context
'with search param'
do
...
...
ee/spec/models/issue_link_spec.rb
View file @
415dbc24
...
...
@@ -56,8 +56,9 @@ describe IssueLink do
link1
=
create
(
:issue_link
,
link_type:
described_class
::
TYPE_BLOCKS
)
link2
=
create
(
:issue_link
,
link_type:
described_class
::
TYPE_IS_BLOCKED_BY
)
link3
=
create
(
:issue_link
,
link_type:
described_class
::
TYPE_RELATES_TO
)
link4
=
create
(
:issue_link
,
source:
create
(
:issue
,
:closed
),
link_type:
described_class
::
TYPE_BLOCKS
)
expect
(
described_class
.
blocked_issue_ids
([
link1
.
target_id
,
link2
.
source_id
,
link3
.
source_id
]))
expect
(
described_class
.
blocked_issue_ids
([
link1
.
target_id
,
link2
.
source_id
,
link3
.
source_id
,
link4
.
target_id
]))
.
to
match_array
([
link1
.
target_id
,
link2
.
source_id
])
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