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
d4d854b3
Commit
d4d854b3
authored
Jan 08, 2021
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move common argument to new concern
- Add request specs - Update schema
parent
73866ca7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
184 additions
and
119 deletions
+184
-119
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+8
-8
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+78
-78
ee/app/graphql/mutations/requirements_management/export_requirements.rb
.../mutations/requirements_management/export_requirements.rb
+1
-16
ee/app/graphql/resolvers/concerns/common_requirement_arguments.rb
...raphql/resolvers/concerns/common_requirement_arguments.rb
+23
-0
ee/app/graphql/resolvers/requirements_management/requirements_resolver.rb
...esolvers/requirements_management/requirements_resolver.rb
+1
-16
ee/spec/requests/api/graphql/mutations/requirements_management/export_requirements_spec.rb
...tions/requirements_management/export_requirements_spec.rb
+72
-0
ee/spec/support/shared_examples/policies/requirement_policy_shared_examples.rb
...d_examples/policies/requirement_policy_shared_examples.rb
+1
-1
No files found.
doc/api/graphql/reference/gitlab_schema.graphql
View file @
d4d854b3
...
...
@@ -18516,7 +18516,7 @@ type Project {
"""
requirement
(
"""
Filter
requirements
by
author
username
Filter
requirements
by
author
username
.
"""
authorUsername
:
[
String
!]
...
...
@@ -18531,17 +18531,17 @@ type Project {
iids
:
[
ID
!]
"""
Search
query
for
requirement
title
Search
query
for
requirement
title
.
"""
search
:
String
"""
List
requirements
by
sort
order
List
requirements
by
sort
order
.
"""
sort
:
Sort
"""
Filter
requirements
by
state
Filter
requirements
by
state
.
"""
state
:
RequirementState
):
Requirement
...
...
@@ -18561,7 +18561,7 @@ type Project {
after
:
String
"""
Filter
requirements
by
author
username
Filter
requirements
by
author
username
.
"""
authorUsername
:
[
String
!]
...
...
@@ -18591,17 +18591,17 @@ type Project {
last
:
Int
"""
Search
query
for
requirement
title
Search
query
for
requirement
title
.
"""
search
:
String
"""
List
requirements
by
sort
order
List
requirements
by
sort
order
.
"""
sort
:
Sort
"""
Filter
requirements
by
state
Filter
requirements
by
state
.
"""
state
:
RequirementState
):
RequirementConnection
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
d4d854b3
...
...
@@ -26214,20 +26214,6 @@
"description": "Autogenerated input type of ExportRequirements",
"fields": null,
"inputFields": [
{
"name": "projectPath",
"description": "Full project path the requirements are associated with.",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "sort",
"description": "List requirements by sort order.",
...
...
@@ -26276,6 +26262,20 @@
},
"defaultValue": null
},
{
"name": "projectPath",
"description": "Full project path the requirements are associated with.",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
...
...
@@ -53997,37 +53997,9 @@
"name": "requirement",
"description": "Find a single requirement",
"args": [
{
"name": "iid",
"description": "IID of the requirement, e.g., \"1\"",
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"defaultValue": null
},
{
"name": "iids",
"description": "List of IIDs of requirements, e.g., [1, 2]",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "sort",
"description": "List requirements by sort order",
"description": "List requirements by sort order
.
",
"type": {
"kind": "ENUM",
"name": "Sort",
...
...
@@ -54037,7 +54009,7 @@
},
{
"name": "state",
"description": "Filter requirements by state",
"description": "Filter requirements by state
.
",
"type": {
"kind": "ENUM",
"name": "RequirementState",
...
...
@@ -54047,7 +54019,7 @@
},
{
"name": "search",
"description": "Search query for requirement title",
"description": "Search query for requirement title
.
",
"type": {
"kind": "SCALAR",
"name": "String",
...
...
@@ -54057,7 +54029,7 @@
},
{
"name": "authorUsername",
"description": "Filter requirements by author username",
"description": "Filter requirements by author username
.
",
"type": {
"kind": "LIST",
"name": null,
...
...
@@ -54072,6 +54044,34 @@
}
},
"defaultValue": null
},
{
"name": "iid",
"description": "IID of the requirement, e.g., \"1\"",
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"defaultValue": null
},
{
"name": "iids",
"description": "List of IIDs of requirements, e.g., [1, 2]",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
}
],
"type": {
...
...
@@ -54100,37 +54100,9 @@
"name": "requirements",
"description": "Find requirements",
"args": [
{
"name": "iid",
"description": "IID of the requirement, e.g., \"1\"",
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"defaultValue": null
},
{
"name": "iids",
"description": "List of IIDs of requirements, e.g., [1, 2]",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "sort",
"description": "List requirements by sort order",
"description": "List requirements by sort order
.
",
"type": {
"kind": "ENUM",
"name": "Sort",
...
...
@@ -54140,7 +54112,7 @@
},
{
"name": "state",
"description": "Filter requirements by state",
"description": "Filter requirements by state
.
",
"type": {
"kind": "ENUM",
"name": "RequirementState",
...
...
@@ -54150,7 +54122,7 @@
},
{
"name": "search",
"description": "Search query for requirement title",
"description": "Search query for requirement title
.
",
"type": {
"kind": "SCALAR",
"name": "String",
...
...
@@ -54160,7 +54132,7 @@
},
{
"name": "authorUsername",
"description": "Filter requirements by author username",
"description": "Filter requirements by author username
.
",
"type": {
"kind": "LIST",
"name": null,
...
...
@@ -54176,6 +54148,34 @@
},
"defaultValue": null
},
{
"name": "iid",
"description": "IID of the requirement, e.g., \"1\"",
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"defaultValue": null
},
{
"name": "iids",
"description": "List of IIDs of requirements, e.g., [1, 2]",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
ee/app/graphql/mutations/requirements_management/export_requirements.rb
View file @
d4d854b3
...
...
@@ -4,6 +4,7 @@ module Mutations
module
RequirementsManagement
class
ExportRequirements
<
BaseMutation
include
ResolvesProject
include
CommonRequirementArguments
graphql_name
'ExportRequirements'
...
...
@@ -13,22 +14,6 @@ module Mutations
required:
true
,
description:
'Full project path the requirements are associated with.'
argument
:sort
,
Types
::
SortEnum
,
required:
false
,
description:
'List requirements by sort order.'
argument
:state
,
Types
::
RequirementsManagement
::
RequirementStateEnum
,
required:
false
,
description:
'Filter requirements by state.'
argument
:search
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Search query for requirement title.'
argument
:author_username
,
[
GraphQL
::
STRING_TYPE
],
required:
false
,
description:
'Filter requirements by author username.'
def
resolve
(
args
)
project_path
=
args
.
delete
(
:project_path
)
project
=
authorized_find!
(
full_path:
project_path
)
...
...
ee/app/graphql/resolvers/concerns/common_requirement_arguments.rb
0 → 100644
View file @
d4d854b3
# frozen_string_literal: true
module
CommonRequirementArguments
extend
ActiveSupport
::
Concern
included
do
argument
:sort
,
Types
::
SortEnum
,
required:
false
,
description:
'List requirements by sort order.'
argument
:state
,
Types
::
RequirementsManagement
::
RequirementStateEnum
,
required:
false
,
description:
'Filter requirements by state.'
argument
:search
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Search query for requirement title.'
argument
:author_username
,
[
GraphQL
::
STRING_TYPE
],
required:
false
,
description:
'Filter requirements by author username.'
end
end
ee/app/graphql/resolvers/requirements_management/requirements_resolver.rb
View file @
d4d854b3
...
...
@@ -4,6 +4,7 @@ module Resolvers
module
RequirementsManagement
class
RequirementsResolver
<
BaseResolver
include
LooksAhead
include
CommonRequirementArguments
type
::
Types
::
RequirementsManagement
::
RequirementType
.
connection_type
,
null:
true
...
...
@@ -15,22 +16,6 @@ module Resolvers
required:
false
,
description:
'List of IIDs of requirements, e.g., [1, 2]'
argument
:sort
,
Types
::
SortEnum
,
required:
false
,
description:
'List requirements by sort order'
argument
:state
,
Types
::
RequirementsManagement
::
RequirementStateEnum
,
required:
false
,
description:
'Filter requirements by state'
argument
:search
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Search query for requirement title'
argument
:author_username
,
[
GraphQL
::
STRING_TYPE
],
required:
false
,
description:
'Filter requirements by author username'
def
resolve_with_lookahead
(
**
args
)
# The project could have been loaded in batch by `BatchLoader`.
# At this point we need the `id` of the project to query for issues, so
...
...
ee/spec/requests/api/graphql/mutations/requirements_management/export_requirements_spec.rb
0 → 100644
View file @
d4d854b3
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Exporting Requirements'
do
include
GraphqlHelpers
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:requirement
)
{
create
(
:requirement
,
project:
project
)
}
let
(
:attributes
)
{
{
state:
'OPENED'
,
author_username:
[
current_user
.
username
],
sort: :CREATED_ASC
,
search:
requirement
.
title
}
}
let
(
:mutation
)
do
params
=
{
project_path:
project
.
full_path
}.
merge
(
attributes
)
graphql_mutation
(
:export_requirements
,
params
)
end
def
mutation_response
graphql_mutation_response
(
:export_requirements
)
end
shared_examples
'requirements export fails'
do
it_behaves_like
'a mutation that returns a top-level access error'
it
'does not schedule export job'
do
expect
(
IssuableExportCsvWorker
).
not_to
receive
(
:perform_async
)
end
end
context
'when the user does not have permission'
do
before
do
stub_licensed_features
(
requirements:
true
)
end
it_behaves_like
'requirements export fails'
end
context
'when the user has permission'
do
before
do
project
.
add_reporter
(
current_user
)
end
context
'when requirements are disabled'
do
before
do
stub_licensed_features
(
requirements:
false
)
end
it_behaves_like
'requirements export fails'
end
context
'when requirements are enabled'
do
before
do
stub_licensed_features
(
requirements:
true
)
end
it
'schedules job to export requirements'
,
:aggregate_failures
do
args
=
{
author_username:
[
current_user
.
username
],
search:
requirement
.
title
,
sort: :created_asc
,
state:
'opened'
}
expect
(
IssuableExportCsvWorker
)
.
to
receive
(
:perform_async
).
with
(
:requirement
,
current_user
.
id
,
project
.
id
,
args
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'errors'
]).
to
be_empty
end
end
end
end
ee/spec/support/shared_examples/policies/requirement_policy_shared_examples.rb
View file @
d4d854b3
...
...
@@ -6,7 +6,7 @@ RSpec.shared_examples 'resource with requirement permissions' do
let
(
:all_permissions
)
do
[
:read_requirement
,
:create_requirement
,
:admin_requirement
,
:update_requirement
,
:destroy_requirement
,
:create_requirement_test_report
]
:create_requirement_test_report
,
:export_requirements
]
end
let
(
:manage_permissions
)
{
all_permissions
-
[
:destroy_requirement
]
}
...
...
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