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:
parent
6507c1085e
commit
f6035552e5
2 changed files with 84 additions and 0 deletions
17
app/models/issue_observer.rb
Normal file
17
app/models/issue_observer.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue