diff options
author | Andrew8xx8 <avk@8xx8.ru> | 2013-02-18 16:49:17 +0400 |
---|---|---|
committer | Andrew8xx8 <avk@8xx8.ru> | 2013-02-18 16:49:17 +0400 |
commit | 231d9e0426b875eda9ea70baaf5dccbcdd463dab (patch) | |
tree | 1d8d2501cfbdf0ca17ff1d6e1b5c46eadcdeffa6 /app | |
parent | 6074896cbfc7f8649e8f7feec1e88de76c2bfbc0 (diff) |
Observer refactored to use StateMachine events
Diffstat (limited to 'app')
-rw-r--r-- | app/observers/activity_observer.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/observers/activity_observer.rb b/app/observers/activity_observer.rb index b568bb6b763..9c72a6d33f9 100644 --- a/app/observers/activity_observer.rb +++ b/app/observers/activity_observer.rb @@ -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 |