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
de7db217
Commit
de7db217
authored
Feb 19, 2021
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to filter requirements with missing status
Filter requirements without test reports on GraphQL
parent
375a76af
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
79 additions
and
8 deletions
+79
-8
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+10
-0
ee/app/finders/requirements_management/requirements_finder.rb
...pp/finders/requirements_management/requirements_finder.rb
+5
-1
ee/app/graphql/resolvers/requirements_management/requirements_resolver.rb
...esolvers/requirements_management/requirements_resolver.rb
+1
-1
ee/app/graphql/types/requirements_management/requirement_status_filter_enum.rb
...requirements_management/requirement_status_filter_enum.rb
+12
-0
ee/app/models/requirements_management/requirement.rb
ee/app/models/requirements_management/requirement.rb
+4
-0
ee/changelogs/unreleased/issue_224614_add_nil_status_filter.yml
...ngelogs/unreleased/issue_224614_add_nil_status_filter.yml
+5
-0
ee/spec/graphql/resolvers/requirements_management/requirements_resolver_spec.rb
...ers/requirements_management/requirements_resolver_spec.rb
+18
-6
ee/spec/models/requirements_management/requirement_spec.rb
ee/spec/models/requirements_management/requirement_spec.rb
+13
-0
ee/spec/requests/api/graphql/project/requirements_management/requirements_spec.rb
...phql/project/requirements_management/requirements_spec.rb
+11
-0
No files found.
doc/api/graphql/reference/index.md
View file @
de7db217
...
...
@@ -5661,6 +5661,16 @@ State of a requirement.
|
`ARCHIVED`
| |
|
`OPENED`
| |
### RequirementStatusFilter
Status of a requirement based on last test report.
| Value | Description |
| ----- | ----------- |
|
`FAILED`
| |
|
`MISSING`
| Requirements without any test report. |
|
`PASSED`
| |
### SastUiComponentSize
Size of UI component in SAST configuration page.
...
...
ee/app/finders/requirements_management/requirements_finder.rb
View file @
de7db217
...
...
@@ -62,7 +62,11 @@ module RequirementsManagement
def
by_last_test_report_state
(
items
)
return
items
unless
params
[
:last_test_report_state
]
items
.
with_last_test_report_state
(
params
[
:last_test_report_state
])
if
params
[
:last_test_report_state
]
==
'missing'
items
.
without_test_reports
else
items
.
with_last_test_report_state
(
params
[
:last_test_report_state
])
end
end
def
get_authors
(
username_param
)
...
...
ee/app/graphql/resolvers/requirements_management/requirements_resolver.rb
View file @
de7db217
...
...
@@ -16,7 +16,7 @@ module Resolvers
required:
false
,
description:
'List of IIDs of requirements, e.g., [1, 2].'
argument
:last_test_report_state
,
::
Types
::
RequirementsManagement
::
TestReportState
Enum
,
argument
:last_test_report_state
,
::
Types
::
RequirementsManagement
::
RequirementStatusFilter
Enum
,
required:
false
,
description:
'The state of latest requirement test report.'
...
...
ee/app/graphql/types/requirements_management/requirement_status_filter_enum.rb
0 → 100644
View file @
de7db217
# frozen_string_literal: true
module
Types
module
RequirementsManagement
class
RequirementStatusFilterEnum
<
TestReportStateEnum
graphql_name
'RequirementStatusFilter'
description
'Status of a requirement based on last test report'
value
'MISSING'
,
value:
'missing'
,
description:
'Requirements without any test report.'
end
end
end
ee/app/models/requirements_management/requirement.rb
View file @
de7db217
...
...
@@ -53,6 +53,10 @@ module RequirementsManagement
include_last_test_report_with_state
.
where
(
test_reports:
{
state:
state
}
)
end
scope
:without_test_reports
,
->
do
left_joins
(
:test_reports
).
where
(
requirements_management_test_reports:
{
requirement_id:
nil
})
end
class
<<
self
# Searches for records with a matching title.
#
...
...
ee/changelogs/unreleased/issue_224614_add_nil_status_filter.yml
0 → 100644
View file @
de7db217
---
title
:
Allow to filter requirements by missing status
merge_request
:
54711
author
:
type
:
added
ee/spec/graphql/resolvers/requirements_management/requirements_resolver_spec.rb
View file @
de7db217
...
...
@@ -42,13 +42,25 @@ RSpec.describe Resolvers::RequirementsManagement::RequirementsResolver do
expect
(
resolve_requirements
(
iids:
[
requirement1
.
iid
,
requirement3
.
iid
])).
to
contain_exactly
(
requirement1
,
requirement3
)
end
it
'filters by last test report state'
do
create
(
:test_report
,
state: :failed
)
create
(
:test_report
,
requirement:
requirement1
,
state: :passed
)
create
(
:test_report
,
requirement:
requirement1
,
state: :failed
)
create
(
:test_report
,
requirement:
requirement3
,
state: :failed
)
context
'when filtering by last test report state'
do
before
do
create
(
:test_report
,
state: :failed
)
create
(
:test_report
,
requirement:
requirement1
,
state: :passed
)
create
(
:test_report
,
requirement:
requirement1
,
state: :failed
)
create
(
:test_report
,
requirement:
requirement3
,
state: :passed
)
end
it
'filters by failed requirements'
do
expect
(
resolve_requirements
(
last_test_report_state:
'failed'
)).
to
contain_exactly
(
requirement1
)
end
expect
(
resolve_requirements
(
last_test_report_state:
'failed'
)).
to
contain_exactly
(
requirement1
,
requirement3
)
it
'filters by passed requirements'
do
expect
(
resolve_requirements
(
last_test_report_state:
'passed'
)).
to
contain_exactly
(
requirement3
)
end
it
'filters requirements without test reports'
do
expect
(
resolve_requirements
(
last_test_report_state:
'missing'
)).
to
contain_exactly
(
requirement2
)
end
end
describe
'sorting'
do
...
...
ee/spec/models/requirements_management/requirement_spec.rb
View file @
de7db217
...
...
@@ -106,6 +106,19 @@ RSpec.describe RequirementsManagement::Requirement do
end
end
describe
'.without_test_reports'
do
let_it_be
(
:requirement1
)
{
create
(
:requirement
)
}
let_it_be
(
:requirement2
)
{
create
(
:requirement
)
}
before
do
create
(
:test_report
,
requirement:
requirement2
,
state: :passed
)
end
it
'returns requirements without test reports'
do
expect
(
described_class
.
without_test_reports
).
to
contain_exactly
(
requirement1
)
end
end
describe
'#last_test_report_state'
do
let_it_be
(
:requirement
)
{
create
(
:requirement
)
}
...
...
ee/spec/requests/api/graphql/project/requirements_management/requirements_spec.rb
View file @
de7db217
...
...
@@ -169,6 +169,17 @@ RSpec.describe 'getting a requirement list for a project' do
match_single_result
(
requirement1
)
end
context
'for MISSING status'
do
let_it_be
(
:requirement3
)
{
create
(
:requirement
,
project:
filter_project
,
author:
other_user
,
title:
'need test report'
)
}
let
(
:params
)
{
'(lastTestReportState: MISSING)'
}
it
'returns filtered requirements'
do
expect
(
graphql_errors
).
to
be_nil
match_single_result
(
requirement3
)
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