Observer refactored to use StateMachine events
This commit is contained in:
parent
6074896cbf
commit
231d9e0426
1 changed files with 12 additions and 4 deletions
|
@ -20,15 +20,23 @@ class ActivityObserver < ActiveRecord::Observer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_save(record)
|
def after_close(record, transition)
|
||||||
if record.changed.include?("closed") && record.author_id_of_changes
|
|
||||||
Event.create(
|
Event.create(
|
||||||
project: record.project,
|
project: record.project,
|
||||||
target_id: record.id,
|
target_id: record.id,
|
||||||
target_type: record.class.name,
|
target_type: record.class.name,
|
||||||
action: (record.closed ? Event::CLOSED : Event::REOPENED),
|
action: Event::CLOSED,
|
||||||
author_id: record.author_id_of_changes
|
author_id: record.author_id_of_changes
|
||||||
)
|
)
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue