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 @@ ...@@ -2,11 +2,11 @@
module IncidentManagement module IncidentManagement
module EscalationPolicies module EscalationPolicies
class BaseService class BaseService < ::BaseProjectService
MAX_RULE_COUNT = 10 MAX_RULE_COUNT = 10
def allowed? def allowed?
user&.can?(:admin_incident_management_escalation_policy, project) current_user&.can?(:admin_incident_management_escalation_policy, project)
end end
def too_many_rules? def too_many_rules?
......
...@@ -4,7 +4,7 @@ module IncidentManagement ...@@ -4,7 +4,7 @@ module IncidentManagement
module EscalationPolicies module EscalationPolicies
class CreateService < EscalationPolicies::BaseService class CreateService < EscalationPolicies::BaseService
# @param [Project] project # @param [Project] project
# @param [User] user # @param [User] current_user
# @param [Hash] params # @param [Hash] params
# @option params [String] name # @option params [String] name
# @option params [String] description # @option params [String] description
...@@ -12,10 +12,8 @@ module IncidentManagement ...@@ -12,10 +12,8 @@ module IncidentManagement
# @option params[:rules_attributes] [IncidentManagement::OncallSchedule] oncall_schedule # @option params[:rules_attributes] [IncidentManagement::OncallSchedule] oncall_schedule
# @option params[:rules_attributes] [Integer] elapsed_time_seconds # @option params[:rules_attributes] [Integer] elapsed_time_seconds
# @option params[:rules_attributes] [String] status # @option params[:rules_attributes] [String] status
def initialize(project, user, params) def initialize(project, current_user, params)
@project = project super(project: project, current_user: current_user, params: params)
@user = user
@params = params
end end
def execute def execute
...@@ -31,10 +29,6 @@ module IncidentManagement ...@@ -31,10 +29,6 @@ module IncidentManagement
success(escalation_policy) success(escalation_policy)
end end
private
attr_reader :project, :user, :params
end end
end end
end end
...@@ -4,11 +4,11 @@ module IncidentManagement ...@@ -4,11 +4,11 @@ module IncidentManagement
module EscalationPolicies module EscalationPolicies
class DestroyService < EscalationPolicies::BaseService class DestroyService < EscalationPolicies::BaseService
# @param escalation_policy [IncidentManagement::EscalationPolicy] # @param escalation_policy [IncidentManagement::EscalationPolicy]
# @param user [User] # @param current_user [User]
def initialize(escalation_policy, user) def initialize(escalation_policy, current_user)
super(project: escalation_policy.project, current_user: current_user)
@escalation_policy = escalation_policy @escalation_policy = escalation_policy
@user = user
@project = escalation_policy.project
end end
def execute def execute
...@@ -23,7 +23,7 @@ module IncidentManagement ...@@ -23,7 +23,7 @@ module IncidentManagement
private private
attr_reader :escalation_policy, :user, :project attr_reader :escalation_policy
end end
end end
end end
...@@ -6,7 +6,7 @@ module IncidentManagement ...@@ -6,7 +6,7 @@ module IncidentManagement
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
# @param escalation_policy [IncidentManagement::EscalationPolicy] # @param escalation_policy [IncidentManagement::EscalationPolicy]
# @param user [User] # @param current_user [User]
# @param params [Hash] # @param params [Hash]
# @option params [String] name # @option params [String] name
# @option params [String] description # @option params [String] description
...@@ -16,11 +16,10 @@ module IncidentManagement ...@@ -16,11 +16,10 @@ module IncidentManagement
# @option params[:rules_attributes] [IncidentManagement::OncallSchedule] oncall_schedule # @option params[:rules_attributes] [IncidentManagement::OncallSchedule] oncall_schedule
# @option params[:rules_attributes] [Integer] elapsed_time_seconds # @option params[:rules_attributes] [Integer] elapsed_time_seconds
# @option params[:rules_attributes] [String, Integer, Symbol] status # @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 @escalation_policy = escalation_policy
@user = user
@params = params
@project = escalation_policy.project
end end
def execute def execute
...@@ -41,7 +40,7 @@ module IncidentManagement ...@@ -41,7 +40,7 @@ module IncidentManagement
private private
attr_reader :escalation_policy, :user, :params, :project attr_reader :escalation_policy
def empty_rules? def empty_rules?
params[:rules_attributes] && params[:rules_attributes].empty? 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