2012-05-17 23:23:34 +02:00
|
|
|
class IssueObserver < ActiveRecord::Observer
|
|
|
|
cattr_accessor :current_user
|
|
|
|
|
|
|
|
def after_create(issue)
|
2013-03-26 08:47:40 +01:00
|
|
|
notification.new_issue(issue, current_user)
|
2012-05-17 23:23:34 +02:00
|
|
|
end
|
|
|
|
|
2013-02-18 10:10:58 +01:00
|
|
|
def after_close(issue, transition)
|
2013-03-26 08:47:40 +01:00
|
|
|
notification.close_issue(issue, current_user)
|
2012-08-29 09:48:17 +02:00
|
|
|
|
2013-02-18 10:10:58 +01:00
|
|
|
create_note(issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_reopen(issue, transition)
|
|
|
|
create_note(issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_update(issue)
|
2013-03-26 08:47:40 +01:00
|
|
|
if issue.is_being_reassigned?
|
|
|
|
notification.reassigned_issue(issue, current_user)
|
|
|
|
end
|
2012-05-20 20:25:34 +02:00
|
|
|
end
|
|
|
|
|
2012-06-21 03:23:05 +02:00
|
|
|
protected
|
|
|
|
|
2013-03-26 08:47:40 +01:00
|
|
|
# Create issue note with service comment like 'Status changed to closed'
|
2013-02-18 10:10:58 +01:00
|
|
|
def create_note(issue)
|
|
|
|
Note.create_status_change_note(issue, current_user, issue.state)
|
|
|
|
end
|
|
|
|
|
2013-03-26 08:47:40 +01:00
|
|
|
def notification
|
|
|
|
NotificationService.new
|
2012-05-17 23:23:34 +02:00
|
|
|
end
|
|
|
|
end
|