2014-06-10 11:07:52 -04:00
|
|
|
module Milestones
|
|
|
|
class UpdateService < Milestones::BaseService
|
|
|
|
def execute(milestone)
|
2014-06-26 16:24:17 -04:00
|
|
|
state = params[:state_event]
|
2014-06-10 11:07:52 -04:00
|
|
|
|
|
|
|
case state
|
2014-06-10 12:22:39 -04:00
|
|
|
when 'activate'
|
2014-06-10 11:07:52 -04:00
|
|
|
Milestones::ReopenService.new(project, current_user, {}).execute(milestone)
|
|
|
|
when 'close'
|
|
|
|
Milestones::CloseService.new(project, current_user, {}).execute(milestone)
|
|
|
|
end
|
|
|
|
|
|
|
|
if params.present?
|
2014-06-26 16:24:17 -04:00
|
|
|
milestone.update_attributes(params.except(:state_event))
|
2014-06-10 11:07:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
milestone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|