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
Hide 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
...
@@ -8,9 +8,7 @@ module Resolvers
type
Types
::
IncidentManagement
::
OncallScheduleType
.
connection_type
,
null:
true
type
Types
::
IncidentManagement
::
OncallScheduleType
.
connection_type
,
null:
true
def
resolve
(
**
args
)
def
resolve
(
**
args
)
return
[]
unless
Ability
.
allowed?
(
current_user
,
:read_incident_management_oncall_schedule
,
project
)
::
IncidentManagement
::
OncallSchedulesFinder
.
new
(
context
[
:current_user
],
project
).
execute
project
.
incident_management_oncall_schedules
end
end
end
end
end
end
...
...
ee/app/models/license.rb
View file @
68aaddce
...
@@ -127,6 +127,7 @@ class License < ApplicationRecord
...
@@ -127,6 +127,7 @@ class License < ApplicationRecord
unprotection_restrictions
unprotection_restrictions
ci_project_subscriptions
ci_project_subscriptions
incident_timeline_view
incident_timeline_view
oncall_schedules
]
]
EEP_FEATURES
.
freeze
EEP_FEATURES
.
freeze
...
...
ee/app/services/incident_management/oncall_schedules/create_service.rb
View file @
68aaddce
...
@@ -13,6 +13,7 @@ module IncidentManagement
...
@@ -13,6 +13,7 @@ module IncidentManagement
end
end
def
execute
def
execute
return
error_no_license
unless
available?
return
error_no_permissions
unless
allowed?
return
error_no_permissions
unless
allowed?
oncall_schedule
=
project
.
incident_management_oncall_schedules
.
create
(
params
)
oncall_schedule
=
project
.
incident_management_oncall_schedules
.
create
(
params
)
...
@@ -29,6 +30,10 @@ module IncidentManagement
...
@@ -29,6 +30,10 @@ module IncidentManagement
user
&
.
can?
(
:modify_incident_management_oncall_schedule
,
project
)
user
&
.
can?
(
:modify_incident_management_oncall_schedule
,
project
)
end
end
def
available?
project
.
feature_available?
(
:oncall_schedules
)
end
def
error
(
message
)
def
error
(
message
)
ServiceResponse
.
error
(
message:
message
)
ServiceResponse
.
error
(
message:
message
)
end
end
...
@@ -41,6 +46,10 @@ module IncidentManagement
...
@@ -41,6 +46,10 @@ module IncidentManagement
error
(
_
(
'You have insufficient permissions to create an on-call schedule for this project'
))
error
(
_
(
'You have insufficient permissions to create an on-call schedule for this project'
))
end
end
def
error_no_license
error
(
_
(
'Your license does not support on-call schedules'
))
end
def
error_in_create
(
oncall_schedule
)
def
error_in_create
(
oncall_schedule
)
error
(
oncall_schedule
.
errors
.
full_messages
.
to_sentence
)
error
(
oncall_schedule
.
errors
.
full_messages
.
to_sentence
)
end
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
...
@@ -21,6 +21,7 @@ RSpec.describe Mutations::IncidentManagement::OncallSchedule::Create do
context
'user has access to project'
do
context
'user has access to project'
do
before
do
before
do
stub_licensed_features
(
oncall_schedules:
true
)
project
.
add_maintainer
(
current_user
)
project
.
add_maintainer
(
current_user
)
end
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
...
@@ -11,23 +11,17 @@ RSpec.describe Resolvers::IncidentManagement::OncallScheduleResolver do
subject
{
sync
(
resolve_oncall_schedules
)
}
subject
{
sync
(
resolve_oncall_schedules
)
}
specify
do
before
do
expect
(
described_class
).
to
have_nullable_graphql_type
(
Types
::
IncidentManagement
::
OncallScheduleType
.
connection_type
)
stub_licensed_features
(
oncall_schedules:
true
)
project
.
add_maintainer
(
current_user
)
end
end
context
'user does not have permissions'
do
specify
do
it
{
is_expected
.
to
eq
(
IncidentManagement
::
OncallSchedule
.
none
)
}
expect
(
described_class
).
to
have_nullable_graphql_type
(
Types
::
IncidentManagement
::
OncallScheduleType
.
connection_type
)
end
end
context
'user has permissions'
do
it
'returns on-call schedules'
do
before
do
is_expected
.
to
contain_exactly
(
oncall_schedule
)
project
.
add_maintainer
(
current_user
)
end
it
{
is_expected
.
to
contain_exactly
(
oncall_schedule
)
}
# TODO: check feature flag
# TODO: check license "Premium"
end
end
private
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
...
@@ -34,6 +34,7 @@ RSpec.describe 'Creating a new on-call schedule' do
let
(
:mutation_response
)
{
graphql_mutation_response
(
:oncall_schedule_create
)
}
let
(
:mutation_response
)
{
graphql_mutation_response
(
:oncall_schedule_create
)
}
before
do
before
do
stub_licensed_features
(
oncall_schedules:
true
)
project
.
add_maintainer
(
current_user
)
project
.
add_maintainer
(
current_user
)
end
end
...
...
ee/spec/requests/api/graphql/project/incident_management/oncall_schedules_spec.rb
View file @
68aaddce
...
@@ -5,7 +5,7 @@ require 'spec_helper'
...
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec
.
describe
'getting Incident Management on-call schedules'
do
RSpec
.
describe
'getting Incident Management on-call schedules'
do
include
GraphqlHelpers
include
GraphqlHelpers
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
_with_refind
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let
(
:params
)
{
{}
}
let
(
:params
)
{
{}
}
...
@@ -28,6 +28,10 @@ RSpec.describe 'getting Incident Management on-call schedules' do
...
@@ -28,6 +28,10 @@ RSpec.describe 'getting Incident Management on-call schedules' do
let
(
:oncall_schedules
)
{
graphql_data
.
dig
(
'project'
,
'incidentManagementOncallSchedules'
,
'nodes'
)
}
let
(
:oncall_schedules
)
{
graphql_data
.
dig
(
'project'
,
'incidentManagementOncallSchedules'
,
'nodes'
)
}
before
do
stub_licensed_features
(
oncall_schedules:
true
)
end
context
'without project permissions'
do
context
'without project permissions'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
@@ -45,6 +49,17 @@ RSpec.describe 'getting Incident Management on-call schedules' do
...
@@ -45,6 +49,17 @@ RSpec.describe 'getting Incident Management on-call schedules' do
project
.
add_maintainer
(
current_user
)
project
.
add_maintainer
(
current_user
)
end
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
context
'without on-call schedules'
do
before
do
before
do
post_graphql
(
query
,
current_user:
current_user
)
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'
...
@@ -5,15 +5,14 @@ require 'spec_helper'
RSpec
.
describe
IncidentManagement
::
OncallSchedules
::
CreateService
do
RSpec
.
describe
IncidentManagement
::
OncallSchedules
::
CreateService
do
let_it_be
(
:user_with_permissions
)
{
create
(
:user
)
}
let_it_be
(
:user_with_permissions
)
{
create
(
:user
)
}
let_it_be
(
:user_without_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
(
:current_user
)
{
user_with_permissions
}
let
(
:params
)
{
{
name:
'On-call schedule'
,
description:
'On-call schedule description'
,
timezone:
'Europe/Berlin'
}
}
let
(
:params
)
{
{
name:
'On-call schedule'
,
description:
'On-call schedule description'
,
timezone:
'Europe/Berlin'
}
}
let
(
:service
)
{
described_class
.
new
(
project
,
current_user
,
params
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
current_user
,
params
)
}
before
do
before
do
stub_licensed_features
(
oncall_schedules:
true
)
project
.
add_maintainer
(
user_with_permissions
)
project
.
add_maintainer
(
user_with_permissions
)
end
end
...
@@ -39,8 +38,16 @@ RSpec.describe IncidentManagement::OncallSchedules::CreateService do
...
@@ -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'
it_behaves_like
'error response'
,
'You have insufficient permissions to create an on-call schedule for this project'
end
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
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'
it_behaves_like
'error response'
,
'Name has already been taken'
end
end
...
...
locale/gitlab.pot
View file @
68aaddce
...
@@ -31262,6 +31262,9 @@ msgstr ""
...
@@ -31262,6 +31262,9 @@ msgstr ""
msgid "You have insufficient permissions to create an HTTP integration for this project"
msgid "You have insufficient permissions to create an HTTP integration for this project"
msgstr ""
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"
msgid "You have insufficient permissions to remove this HTTP integration"
msgstr ""
msgstr ""
...
@@ -31628,6 +31631,9 @@ msgstr ""
...
@@ -31628,6 +31631,9 @@ msgstr ""
msgid "Your issues will be imported in the background. Once finished, you'll get a confirmation email."
msgid "Your issues will be imported in the background. Once finished, you'll get a confirmation email."
msgstr ""
msgstr ""
msgid "Your license does not support on-call schedules"
msgstr ""
msgid "Your license is valid from"
msgid "Your license is valid from"
msgstr ""
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