2018-07-17 16:50:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-06-10 15:07:52 +00:00
|
|
|
module Milestones
|
|
|
|
class UpdateService < Milestones::BaseService
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2014-06-10 15:07:52 +00:00
|
|
|
def execute(milestone)
|
2014-06-26 20:24:17 +00:00
|
|
|
state = params[:state_event]
|
2014-06-10 15:07:52 +00:00
|
|
|
|
|
|
|
case state
|
2014-06-10 16:22:39 +00:00
|
|
|
when 'activate'
|
2017-07-07 15:08:49 +00:00
|
|
|
Milestones::ReopenService.new(parent, current_user, {}).execute(milestone)
|
2014-06-10 15:07:52 +00:00
|
|
|
when 'close'
|
2017-07-07 15:08:49 +00:00
|
|
|
Milestones::CloseService.new(parent, current_user, {}).execute(milestone)
|
2014-06-10 15:07:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if params.present?
|
2018-07-02 10:43:06 +00:00
|
|
|
milestone.update(params.except(:state_event))
|
2014-06-10 15:07:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
milestone
|
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2014-06-10 15:07:52 +00:00
|
|
|
end
|
|
|
|
end
|