Commit 7822b2ed authored by Sean McGivern's avatar Sean McGivern

Merge branch 'sy-swap-escalation-policies-services-base' into 'master'

Swap EscalationPolicies::BaseService to use ::BaseProjectService

See merge request gitlab-org/gitlab!84657
parents 54cfea20 14c7671f
......@@ -2,11 +2,11 @@
module IncidentManagement
module EscalationPolicies
class BaseService
class BaseService < ::BaseProjectService
MAX_RULE_COUNT = 10
def allowed?
user&.can?(:admin_incident_management_escalation_policy, project)
current_user&.can?(:admin_incident_management_escalation_policy, project)
end
def too_many_rules?
......
......@@ -4,7 +4,7 @@ module IncidentManagement
module EscalationPolicies
class CreateService < EscalationPolicies::BaseService
# @param [Project] project
# @param [User] user
# @param [User] current_user
# @param [Hash] params
# @option params [String] name
# @option params [String] description
......@@ -12,10 +12,8 @@ module IncidentManagement
# @option params[:rules_attributes] [IncidentManagement::OncallSchedule] oncall_schedule
# @option params[:rules_attributes] [Integer] elapsed_time_seconds
# @option params[:rules_attributes] [String] status
def initialize(project, user, params)
@project = project
@user = user
@params = params
def initialize(project, current_user, params)
super(project: project, current_user: current_user, params: params)
end
def execute
......@@ -31,10 +29,6 @@ module IncidentManagement
success(escalation_policy)
end
private
attr_reader :project, :user, :params
end
end
end
......@@ -4,11 +4,11 @@ module IncidentManagement
module EscalationPolicies
class DestroyService < EscalationPolicies::BaseService
# @param escalation_policy [IncidentManagement::EscalationPolicy]
# @param user [User]
def initialize(escalation_policy, user)
# @param current_user [User]
def initialize(escalation_policy, current_user)
super(project: escalation_policy.project, current_user: current_user)
@escalation_policy = escalation_policy
@user = user
@project = escalation_policy.project
end
def execute
......@@ -23,7 +23,7 @@ module IncidentManagement
private
attr_reader :escalation_policy, :user, :project
attr_reader :escalation_policy
end
end
end
......@@ -6,7 +6,7 @@ module IncidentManagement
include Gitlab::Utils::StrongMemoize
# @param escalation_policy [IncidentManagement::EscalationPolicy]
# @param user [User]
# @param current_user [User]
# @param params [Hash]
# @option params [String] name
# @option params [String] description
......@@ -16,11 +16,10 @@ module IncidentManagement
# @option params[:rules_attributes] [IncidentManagement::OncallSchedule] oncall_schedule
# @option params[:rules_attributes] [Integer] elapsed_time_seconds
# @option params[:rules_attributes] [String, Integer, Symbol] status
def initialize(escalation_policy, user, params)
def initialize(escalation_policy, current_user, params)
super(project: escalation_policy.project, current_user: current_user, params: params)
@escalation_policy = escalation_policy
@user = user
@params = params
@project = escalation_policy.project
end
def execute
......@@ -41,7 +40,7 @@ module IncidentManagement
private
attr_reader :escalation_policy, :user, :params, :project
attr_reader :escalation_policy
def empty_rules?
params[:rules_attributes] && params[:rules_attributes].empty?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment