Observer refactored to use StateMachine events
This commit is contained in:
parent
6074896cbf
commit
231d9e0426
|
@ -20,15 +20,23 @@ class ActivityObserver < ActiveRecord::Observer
|
|||
end
|
||||
end
|
||||
|
||||
def after_save(record)
|
||||
if record.changed.include?("closed") && record.author_id_of_changes
|
||||
def after_close(record, transition)
|
||||
Event.create(
|
||||
project: record.project,
|
||||
target_id: record.id,
|
||||
target_type: record.class.name,
|
||||
action: (record.closed ? Event::CLOSED : Event::REOPENED),
|
||||
action: Event::CLOSED,
|
||||
author_id: record.author_id_of_changes
|
||||
)
|
||||
end
|
||||
|
||||
def after_reopen(record, transition)
|
||||
Event.create(
|
||||
project: record.project,
|
||||
target_id: record.id,
|
||||
target_type: record.class.name,
|
||||
action: Event::REOPENED,
|
||||
author_id: record.author_id_of_changes
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue