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
92da3222
Commit
92da3222
authored
Nov 30, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract on-call schedules license check
Extract on-call schedules license check into policy and a single method
parent
5890106c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
14 deletions
+49
-14
ee/app/finders/incident_management/oncall_schedules_finder.rb
...pp/finders/incident_management/oncall_schedules_finder.rb
+1
-6
ee/app/policies/ee/project_policy.rb
ee/app/policies/ee/project_policy.rb
+1
-2
ee/app/services/incident_management/oncall_schedules/create_service.rb
...es/incident_management/oncall_schedules/create_service.rb
+1
-2
ee/app/services/incident_management/oncall_schedules/destroy_service.rb
...s/incident_management/oncall_schedules/destroy_service.rb
+1
-2
ee/app/services/incident_management/oncall_schedules/update_service.rb
...es/incident_management/oncall_schedules/update_service.rb
+1
-2
ee/lib/gitlab/incident_management.rb
ee/lib/gitlab/incident_management.rb
+10
-0
ee/spec/lib/gitlab/incident_management_spec.rb
ee/spec/lib/gitlab/incident_management_spec.rb
+34
-0
No files found.
ee/app/finders/incident_management/oncall_schedules_finder.rb
View file @
92da3222
...
@@ -9,7 +9,7 @@ module IncidentManagement
...
@@ -9,7 +9,7 @@ module IncidentManagement
end
end
def
execute
def
execute
return
IncidentManagement
::
OncallSchedule
.
none
unless
a
vailable?
&&
a
llowed?
return
IncidentManagement
::
OncallSchedule
.
none
unless
allowed?
collection
=
project
.
incident_management_oncall_schedules
collection
=
project
.
incident_management_oncall_schedules
collection
=
by_iid
(
collection
)
collection
=
by_iid
(
collection
)
...
@@ -21,11 +21,6 @@ module IncidentManagement
...
@@ -21,11 +21,6 @@ module IncidentManagement
attr_reader
:current_user
,
:project
,
:params
attr_reader
:current_user
,
:project
,
:params
def
available?
Feature
.
enabled?
(
:oncall_schedules_mvc
,
project
)
&&
project
.
feature_available?
(
:oncall_schedules
)
end
def
allowed?
def
allowed?
Ability
.
allowed?
(
current_user
,
:read_incident_management_oncall_schedule
,
project
)
Ability
.
allowed?
(
current_user
,
:read_incident_management_oncall_schedule
,
project
)
end
end
...
...
ee/app/policies/ee/project_policy.rb
View file @
92da3222
...
@@ -155,8 +155,7 @@ module EE
...
@@ -155,8 +155,7 @@ module EE
with_scope
:subject
with_scope
:subject
condition
(
:oncall_schedules_available
)
do
condition
(
:oncall_schedules_available
)
do
::
Feature
.
enabled?
(
:oncall_schedules_mvc
,
@subject
)
&&
::
Gitlab
::
IncidentManagement
.
oncall_schedules_available?
(
@subject
)
@subject
.
feature_available?
(
:oncall_schedules
)
end
end
rule
{
visual_review_bot
}.
policy
do
rule
{
visual_review_bot
}.
policy
do
...
...
ee/app/services/incident_management/oncall_schedules/create_service.rb
View file @
92da3222
...
@@ -31,8 +31,7 @@ module IncidentManagement
...
@@ -31,8 +31,7 @@ module IncidentManagement
end
end
def
available?
def
available?
Feature
.
enabled?
(
:oncall_schedules_mvc
,
project
)
&&
::
Gitlab
::
IncidentManagement
.
oncall_schedules_available?
(
project
)
project
.
feature_available?
(
:oncall_schedules
)
end
end
def
error
(
message
)
def
error
(
message
)
...
...
ee/app/services/incident_management/oncall_schedules/destroy_service.rb
View file @
92da3222
...
@@ -31,8 +31,7 @@ module IncidentManagement
...
@@ -31,8 +31,7 @@ module IncidentManagement
end
end
def
available?
def
available?
Feature
.
enabled?
(
:oncall_schedules_mvc
,
project
)
&&
::
Gitlab
::
IncidentManagement
.
oncall_schedules_available?
(
project
)
project
.
feature_available?
(
:oncall_schedules
)
end
end
def
error
(
message
)
def
error
(
message
)
...
...
ee/app/services/incident_management/oncall_schedules/update_service.rb
View file @
92da3222
...
@@ -33,8 +33,7 @@ module IncidentManagement
...
@@ -33,8 +33,7 @@ module IncidentManagement
end
end
def
available?
def
available?
Feature
.
enabled?
(
:oncall_schedules_mvc
,
project
)
&&
::
Gitlab
::
IncidentManagement
.
oncall_schedules_available?
(
project
)
project
.
feature_available?
(
:oncall_schedules
)
end
end
def
error
(
message
)
def
error
(
message
)
...
...
ee/lib/gitlab/incident_management.rb
0 → 100644
View file @
92da3222
# frozen_string_literal: true
module
Gitlab
module
IncidentManagement
def
self
.
oncall_schedules_available?
(
project
)
::
Feature
.
enabled?
(
:oncall_schedules_mvc
,
project
)
&&
project
.
feature_available?
(
:oncall_schedules
)
end
end
end
ee/spec/lib/gitlab/incident_management_spec.rb
0 → 100644
View file @
92da3222
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
IncidentManagement
do
let_it_be_with_refind
(
:project
)
{
create
(
:project
)
}
describe
'.oncall_schedules_available?'
do
subject
{
described_class
.
oncall_schedules_available?
(
project
)
}
before
do
stub_licensed_features
(
oncall_schedules:
true
)
stub_feature_flags
(
oncall_schedules_mvc:
project
)
end
it
{
is_expected
.
to
be_truthy
}
context
'when feature flag is disabled'
do
before
do
stub_feature_flags
(
oncall_schedules_mvc:
false
)
end
it
{
is_expected
.
to
be_falsey
}
end
context
'when there is no license'
do
before
do
stub_licensed_features
(
oncall_schedules:
false
)
end
it
{
is_expected
.
to
be_falsey
}
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