New IssueObserver class and spec.

Handles emails for new issues and reassigned issues.
Need to add creating a Note on Issue close.
This commit is contained in:
Robb Kidd 2012-05-17 17:23:34 -04:00
parent 6507c1085e
commit f6035552e5
2 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,17 @@
class IssueObserver < ActiveRecord::Observer
cattr_accessor :current_user
def after_create(issue)
Notify.new_issue_email(issue.id) if issue.assignee != current_user
end
def after_change(issue)
if issue.assignee_id_changed?
recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id }
recipient_ids.each do |recipient_id|
Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was)
end
end
end
end