gitlabhq/app/observers/activity_observer.rb
Robert Speicher 7754189187 Fully embrace Ruby 1.9 hash syntax
Didn't bother with files in db/, config/, or features/
2012-08-10 18:25:15 -04:00

26 lines
647 B
Ruby

class ActivityObserver < ActiveRecord::Observer
observe :issue, :merge_request
def after_create(record)
Event.create(
project: record.project,
target_id: record.id,
target_type: record.class.name,
action: Event.determine_action(record),
author_id: record.author_id
)
end
def after_save(record)
if record.changed.include?("closed")
Event.create(
project: record.project,
target_id: record.id,
target_type: record.class.name,
action: (record.closed ? Event::Closed : Event::Reopened),
author_id: record.author_id_of_changes
)
end
end
end