blob: 90cb8ea9f5ceaf513b827e39cc1df21c6dc9b0aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
module Milestones
class UpdateService < Milestones::BaseService
def execute(milestone)
state = params[:state_event]
case state
when 'activate'
Milestones::ReopenService.new(parent, current_user, {}).execute(milestone)
when 'close'
Milestones::CloseService.new(parent, current_user, {}).execute(milestone)
end
if params.present?
milestone.assign_attributes(params.except(:state_event))
end
if milestone.changed?
before_update(milestone)
end
milestone.save
milestone
end
private
def before_update(milestone)
milestone.check_for_spam(user: current_user, action: :update)
end
end
end
Milestones::UpdateService.prepend_mod_with('Milestones::UpdateService')
|