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
279cb5d7
Commit
279cb5d7
authored
Nov 12, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a IncidentManagement::OncallScheduleResolver
Add a GraphQL resolver for on-call schedules
parent
af318c1b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
1 deletion
+136
-1
ee/app/graphql/ee/types/project_type.rb
ee/app/graphql/ee/types/project_type.rb
+2
-1
ee/app/graphql/resolvers/incident_management/oncall_schedule_resolver.rb
...resolvers/incident_management/oncall_schedule_resolver.rb
+18
-0
ee/spec/graphql/resolvers/incident_management/oncall_schedule_resolver_spec.rb
...vers/incident_management/oncall_schedule_resolver_spec.rb
+38
-0
ee/spec/requests/api/graphql/project/incident_management/oncall_schedules_spec.rb
...phql/project/incident_management/oncall_schedules_spec.rb
+78
-0
No files found.
ee/app/graphql/ee/types/project_type.rb
View file @
279cb5d7
...
...
@@ -151,7 +151,8 @@ module EE
field
:incident_management_oncall_schedules
,
::
Types
::
IncidentManagement
::
OncallScheduleType
.
connection_type
,
null:
true
,
description:
'Incident Management On-call schedules of the project'
description:
'Incident Management On-call schedules of the project'
,
resolver:
::
Resolvers
::
IncidentManagement
::
OncallScheduleResolver
def
self
.
sast_ci_configuration
(
project
)
::
Security
::
CiConfiguration
::
SastParserService
.
new
(
project
).
configuration
...
...
ee/app/graphql/resolvers/incident_management/oncall_schedule_resolver.rb
0 → 100644
View file @
279cb5d7
# frozen_string_literal: true
module
Resolvers
module
IncidentManagement
class
OncallScheduleResolver
<
BaseResolver
alias_method
:project
,
:synchronized_object
type
Types
::
IncidentManagement
::
OncallScheduleType
.
connection_type
,
null:
true
def
resolve
(
**
args
)
return
[]
unless
Ability
.
allowed?
(
current_user
,
:read_incident_management_oncall_schedule
,
project
)
project
.
incident_management_oncall_schedules
end
end
end
end
ee/spec/graphql/resolvers/incident_management/oncall_schedule_resolver_spec.rb
0 → 100644
View file @
279cb5d7
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Resolvers
::
IncidentManagement
::
OncallScheduleResolver
do
include
GraphqlHelpers
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:oncall_schedule
)
{
create
(
:incident_management_oncall_schedule
,
project:
project
)
}
subject
{
sync
(
resolve_oncall_schedules
)
}
specify
do
expect
(
described_class
).
to
have_nullable_graphql_type
(
Types
::
IncidentManagement
::
OncallScheduleType
.
connection_type
)
end
context
'user does not have permissions'
do
it
{
is_expected
.
to
eq
(
IncidentManagement
::
OncallSchedule
.
none
)
}
end
context
'user has permissions'
do
before
do
project
.
add_maintainer
(
current_user
)
end
it
{
is_expected
.
to
contain_exactly
(
oncall_schedule
)
}
# TODO: check feature flag
# TODO: check license "Premium"
end
private
def
resolve_oncall_schedules
(
args
=
{},
context
=
{
current_user:
current_user
})
resolve
(
described_class
,
obj:
project
,
args:
args
,
ctx:
context
)
end
end
ee/spec/requests/api/graphql/project/incident_management/oncall_schedules_spec.rb
0 → 100644
View file @
279cb5d7
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'getting Incident Management on-call schedules'
do
include
GraphqlHelpers
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let
(
:params
)
{
{}
}
let
(
:fields
)
do
<<~
QUERY
nodes {
#{
all_graphql_fields_for
(
'IncidentManagementOncallSchedule'
)
}
}
QUERY
end
let
(
:query
)
do
graphql_query_for
(
'project'
,
{
'fullPath'
=>
project
.
full_path
},
query_graphql_field
(
'incidentManagementOncallSchedules'
,
{},
fields
)
)
end
let
(
:oncall_schedules
)
{
graphql_data
.
dig
(
'project'
,
'incidentManagementOncallSchedules'
,
'nodes'
)
}
context
'without project permissions'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
it
{
expect
(
oncall_schedules
).
to
be_nil
}
end
context
'with project permissions'
do
before
do
project
.
add_maintainer
(
current_user
)
end
context
'without on-call schedules'
do
before
do
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
it
{
expect
(
oncall_schedules
).
to
be_empty
}
end
context
'with on-call schedules'
do
let!
(
:oncall_schedule
)
{
create
(
:incident_management_oncall_schedule
,
project:
project
)
}
let
(
:last_oncall_schedule
)
{
oncall_schedules
.
last
}
before
do
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
it
'returns the correct properties of the on-call schedule'
do
expect
(
last_oncall_schedule
).
to
include
(
'iid'
=>
oncall_schedule
.
iid
.
to_s
,
'name'
=>
oncall_schedule
.
name
,
'description'
=>
oncall_schedule
.
description
,
'timezone'
=>
oncall_schedule
.
timezone
)
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