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
08492fdc
Commit
08492fdc
authored
May 04, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filter out deleted issues
parent
b9b273ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
app/services/related_issues/list_service.rb
app/services/related_issues/list_service.rb
+2
-2
spec/services/related_issues/list_service_spec.rb
spec/services/related_issues/list_service_spec.rb
+42
-1
No files found.
app/services/related_issues/list_service.rb
View file @
08492fdc
...
...
@@ -31,11 +31,11 @@ module RelatedIssues
<<-
SQL
.
strip_heredoc
SELECT issues.*, related_issues.id as related_issues_id FROM issues
INNER JOIN related_issues ON related_issues.related_issue_id = issues.id
WHERE related_issues.issue_id =
#{
@issue
.
id
}
WHERE related_issues.issue_id =
#{
@issue
.
id
}
AND issues.deleted_at IS NULL
UNION ALL
SELECT issues.*, related_issues.id as related_issues_id FROM issues
INNER JOIN related_issues ON related_issues.issue_id = issues.id
WHERE related_issues.related_issue_id =
#{
@issue
.
id
}
WHERE related_issues.related_issue_id =
#{
@issue
.
id
}
AND issues.deleted_at IS NULL
ORDER BY related_issues_id
SQL
)
...
...
spec/services/related_issues/list_service_spec.rb
View file @
08492fdc
...
...
@@ -37,7 +37,7 @@ describe RelatedIssues::ListService, service: true do
it
'verifies number of queries'
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
recorded
.
count
).
to
be_within
(
1
).
of
(
39
)
expect
(
recorded
.
count
).
to
be_within
(
1
).
of
(
42
)
end
it
'returns related issues JSON'
do
...
...
@@ -84,6 +84,47 @@ describe RelatedIssues::ListService, service: true do
end
end
context
'referencing issue with removed relationships'
do
context
'when referenced a deleted issue'
do
let
(
:issue_b
)
{
create
:issue
,
project:
project
}
let!
(
:related_issue
)
do
create
(
:related_issue
,
issue:
issue
,
related_issue:
issue_b
)
end
it
'ignores issue'
do
issue_b
.
destroy!
is_expected
.
to
eq
([])
end
end
context
'when referenced an issue with deleted project'
do
let
(
:issue_b
)
{
create
:issue
,
project:
project
}
let!
(
:related_issue
)
do
create
(
:related_issue
,
issue:
issue
,
related_issue:
issue_b
)
end
it
'ignores issue'
do
project
.
destroy!
is_expected
.
to
eq
([])
end
end
context
'when referenced an issue with deleted namespace'
do
let
(
:issue_b
)
{
create
:issue
,
project:
project
}
let!
(
:related_issue
)
do
create
(
:related_issue
,
issue:
issue
,
related_issue:
issue_b
)
end
it
'ignores issue'
do
project
.
namespace
.
destroy!
is_expected
.
to
eq
([])
end
end
end
context
'user cannot see relations'
do
context
'when user cannot see the referenced issue'
do
let!
(
:related_issue
)
do
...
...
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