2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
module Milestones
|
|
|
|
class UpdateService < Milestones::BaseService
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2014-09-02 18:07:02 +05:30
|
|
|
def execute(milestone)
|
|
|
|
state = params[:state_event]
|
|
|
|
|
|
|
|
case state
|
|
|
|
when 'activate'
|
2017-09-10 17:25:29 +05:30
|
|
|
Milestones::ReopenService.new(parent, current_user, {}).execute(milestone)
|
2014-09-02 18:07:02 +05:30
|
|
|
when 'close'
|
2017-09-10 17:25:29 +05:30
|
|
|
Milestones::CloseService.new(parent, current_user, {}).execute(milestone)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
if params.present?
|
2018-11-18 11:00:15 +05:30
|
|
|
milestone.update(params.except(:state_event))
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
milestone
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|