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
68aaddce
Commit
68aaddce
authored
Nov 13, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On-call schedules are GitLab Premium
On-call schedules available in GitLab Premium
parent
599047fe
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
124 additions
and
21 deletions
+124
-21
ee/app/finders/incident_management/oncall_schedules_finder.rb
...pp/finders/incident_management/oncall_schedules_finder.rb
+29
-0
ee/app/graphql/resolvers/incident_management/oncall_schedule_resolver.rb
...resolvers/incident_management/oncall_schedule_resolver.rb
+1
-3
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/app/services/incident_management/oncall_schedules/create_service.rb
...es/incident_management/oncall_schedules/create_service.rb
+9
-0
ee/spec/finders/incident_management/oncall_schedules_finder_spec.rb
...nders/incident_management/oncall_schedules_finder_spec.rb
+42
-0
ee/spec/graphql/mutations/incident_management/oncall_schedule/create_spec.rb
...ations/incident_management/oncall_schedule/create_spec.rb
+1
-0
ee/spec/graphql/resolvers/incident_management/oncall_schedule_resolver_spec.rb
...vers/incident_management/oncall_schedule_resolver_spec.rb
+7
-13
ee/spec/requests/api/graphql/mutations/incident_management/oncall_schedule/create_spec.rb
...ations/incident_management/oncall_schedule/create_spec.rb
+1
-0
ee/spec/requests/api/graphql/project/incident_management/oncall_schedules_spec.rb
...phql/project/incident_management/oncall_schedules_spec.rb
+16
-1
ee/spec/services/incident_management/oncall_schedules/create_service_spec.rb
...cident_management/oncall_schedules/create_service_spec.rb
+11
-4
locale/gitlab.pot
locale/gitlab.pot
+6
-0
No files found.
ee/app/finders/incident_management/oncall_schedules_finder.rb
0 → 100644
View file @
68aaddce
# frozen_string_literal: true
module
IncidentManagement
class
OncallSchedulesFinder
def
initialize
(
current_user
,
project
,
params
=
{})
@current_user
=
current_user
@project
=
project
@params
=
params
end
def
execute
return
IncidentManagement
::
OncallSchedule
.
none
unless
available?
&&
allowed?
project
.
incident_management_oncall_schedules
end
private
attr_reader
:current_user
,
:project
,
:params
def
available?
project
.
feature_available?
(
:oncall_schedules
)
end
def
allowed?
Ability
.
allowed?
(
current_user
,
:read_incident_management_oncall_schedule
,
project
)
end
end
end
ee/app/graphql/resolvers/incident_management/oncall_schedule_resolver.rb
View file @
68aaddce
...
...
@@ -8,9 +8,7 @@ module Resolvers
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
::
IncidentManagement
::
OncallSchedulesFinder
.
new
(
context
[
:current_user
],
project
).
execute
end
end
end
...
...
ee/app/models/license.rb
View file @
68aaddce
...
...
@@ -127,6 +127,7 @@ class License < ApplicationRecord
unprotection_restrictions
ci_project_subscriptions
incident_timeline_view
oncall_schedules
]
EEP_FEATURES
.
freeze
...
...
ee/app/services/incident_management/oncall_schedules/create_service.rb
View file @
68aaddce
...
...
@@ -13,6 +13,7 @@ module IncidentManagement
end
def
execute
return
error_no_license
unless
available?
return
error_no_permissions
unless
allowed?
oncall_schedule
=
project
.
incident_management_oncall_schedules
.
create
(
params
)
...
...
@@ -29,6 +30,10 @@ module IncidentManagement
user
&
.
can?
(
:modify_incident_management_oncall_schedule
,
project
)
end
def
available?
project
.
feature_available?
(
:oncall_schedules
)
end
def
error
(
message
)
ServiceResponse
.
error
(
message:
message
)
end
...
...
@@ -41,6 +46,10 @@ module IncidentManagement
error
(
_
(
'You have insufficient permissions to create an on-call schedule for this project'
))
end
def
error_no_license
error
(
_
(
'Your license does not support on-call schedules'
))
end
def
error_in_create
(
oncall_schedule
)
error
(
oncall_schedule
.
errors
.
full_messages
.
to_sentence
)
end
...
...
ee/spec/finders/incident_management/oncall_schedules_finder_spec.rb
0 → 100644
View file @
68aaddce
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
IncidentManagement
::
OncallSchedulesFinder
do
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be_with_refind
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:oncall_schedule
)
{
create
(
:incident_management_oncall_schedule
,
project:
project
)
}
let_it_be
(
:another_oncall_schedule
)
{
create
(
:incident_management_oncall_schedule
)
}
describe
'#execute'
do
subject
(
:execute
)
{
described_class
.
new
(
current_user
,
project
).
execute
}
context
'when feature is available'
do
before
do
stub_licensed_features
(
oncall_schedules:
true
)
end
context
'when user has permissions'
do
before
do
project
.
add_maintainer
(
current_user
)
end
it
'returns project on-call schedules'
do
is_expected
.
to
contain_exactly
(
oncall_schedule
)
end
end
context
'when user has no permissions'
do
it
{
is_expected
.
to
eq
(
IncidentManagement
::
OncallSchedule
.
none
)
}
end
end
context
'when feature is not avaiable'
do
before
do
stub_licensed_features
(
oncall_schedules:
false
)
end
it
{
is_expected
.
to
eq
(
IncidentManagement
::
OncallSchedule
.
none
)
}
end
end
end
ee/spec/graphql/mutations/incident_management/oncall_schedule/create_spec.rb
View file @
68aaddce
...
...
@@ -21,6 +21,7 @@ RSpec.describe Mutations::IncidentManagement::OncallSchedule::Create do
context
'user has access to project'
do
before
do
stub_licensed_features
(
oncall_schedules:
true
)
project
.
add_maintainer
(
current_user
)
end
...
...
ee/spec/graphql/resolvers/incident_management/oncall_schedule_resolver_spec.rb
View file @
68aaddce
...
...
@@ -11,23 +11,17 @@ RSpec.describe Resolvers::IncidentManagement::OncallScheduleResolver do
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
stub_licensed_features
(
oncall_schedules:
true
)
project
.
add_maintainer
(
current_user
)
end
it
{
is_expected
.
to
contain_exactly
(
oncall_schedule
)
}
specify
do
expect
(
described_class
).
to
have_nullable_graphql_type
(
Types
::
IncidentManagement
::
OncallScheduleType
.
connection_type
)
end
# TODO: check feature flag
# TODO: check license "Premium"
it
'returns on-call schedules'
do
is_expected
.
to
contain_exactly
(
oncall_schedule
)
end
private
...
...
ee/spec/requests/api/graphql/mutations/incident_management/oncall_schedule/create_spec.rb
View file @
68aaddce
...
...
@@ -34,6 +34,7 @@ RSpec.describe 'Creating a new on-call schedule' do
let
(
:mutation_response
)
{
graphql_mutation_response
(
:oncall_schedule_create
)
}
before
do
stub_licensed_features
(
oncall_schedules:
true
)
project
.
add_maintainer
(
current_user
)
end
...
...
ee/spec/requests/api/graphql/project/incident_management/oncall_schedules_spec.rb
View file @
68aaddce
...
...
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec
.
describe
'getting Incident Management on-call schedules'
do
include
GraphqlHelpers
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
_with_refind
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let
(
:params
)
{
{}
}
...
...
@@ -28,6 +28,10 @@ RSpec.describe 'getting Incident Management on-call schedules' do
let
(
:oncall_schedules
)
{
graphql_data
.
dig
(
'project'
,
'incidentManagementOncallSchedules'
,
'nodes'
)
}
before
do
stub_licensed_features
(
oncall_schedules:
true
)
end
context
'without project permissions'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -45,6 +49,17 @@ RSpec.describe 'getting Incident Management on-call schedules' do
project
.
add_maintainer
(
current_user
)
end
context
'with unavailable feature'
do
before
do
stub_licensed_features
(
oncall_schedules:
false
)
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
it
{
expect
(
oncall_schedules
).
to
be_empty
}
end
context
'without on-call schedules'
do
before
do
post_graphql
(
query
,
current_user:
current_user
)
...
...
ee/spec/services/incident_management/oncall_schedules/create_service_spec.rb
View file @
68aaddce
...
...
@@ -5,15 +5,14 @@ require 'spec_helper'
RSpec
.
describe
IncidentManagement
::
OncallSchedules
::
CreateService
do
let_it_be
(
:user_with_permissions
)
{
create
(
:user
)
}
let_it_be
(
:user_without_permissions
)
{
create
(
:user
)
}
let_it_be_with_re
loa
d
(
:project
)
{
create
(
:project
)
}
let_it_be_with_re
fin
d
(
:project
)
{
create
(
:project
)
}
let
(
:current_user
)
{
user_with_permissions
}
let
(
:params
)
{
{
name:
'On-call schedule'
,
description:
'On-call schedule description'
,
timezone:
'Europe/Berlin'
}
}
let
(
:service
)
{
described_class
.
new
(
project
,
current_user
,
params
)
}
before
do
stub_licensed_features
(
oncall_schedules:
true
)
project
.
add_maintainer
(
user_with_permissions
)
end
...
...
@@ -39,8 +38,16 @@ RSpec.describe IncidentManagement::OncallSchedules::CreateService do
it_behaves_like
'error response'
,
'You have insufficient permissions to create an on-call schedule for this project'
end
context
'when feature is not available'
do
before
do
stub_licensed_features
(
oncall_schedules:
false
)
end
it_behaves_like
'error response'
,
'Your license does not support on-call schedules'
end
context
'when an on-call schedule already exists'
do
let
_it_be
(
:oncall_schedule
)
{
create
(
:incident_management_oncall_schedule
,
project:
project
,
name:
'On-call schedule'
)
}
let
!
(
:oncall_schedule
)
{
create
(
:incident_management_oncall_schedule
,
project:
project
,
name:
'On-call schedule'
)
}
it_behaves_like
'error response'
,
'Name has already been taken'
end
...
...
locale/gitlab.pot
View file @
68aaddce
...
...
@@ -31262,6 +31262,9 @@ msgstr ""
msgid "You have insufficient permissions to create an HTTP integration for this project"
msgstr ""
msgid "You have insufficient permissions to create an on-call schedule for this project"
msgstr ""
msgid "You have insufficient permissions to remove this HTTP integration"
msgstr ""
...
...
@@ -31628,6 +31631,9 @@ msgstr ""
msgid "Your issues will be imported in the background. Once finished, you'll get a confirmation email."
msgstr ""
msgid "Your license does not support on-call schedules"
msgstr ""
msgid "Your license is valid from"
msgstr ""
...
...
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