Add method for an issue to know whether it is being closed

Update IssueObserver to create a Note on the issue its being closed.
This commit is contained in:
Robb Kidd 2012-05-20 15:06:13 -04:00
parent 02924de3e1
commit 356430c3c0
4 changed files with 56 additions and 10 deletions

View file

@ -64,6 +64,10 @@ class Issue < ActiveRecord::Base
def is_being_reassigned?
assignee_id_changed?
end
def is_being_closed?
closed_changed? && closed
end
end
# == Schema Information
#

View file

@ -7,6 +7,7 @@ class IssueObserver < ActiveRecord::Observer
def after_change(issue)
send_reassigned_email(issue) if issue.is_being_reassigned?
Note.create_status_change_note(issue, current_user, 'closed') if issue.is_being_closed?
end
def send_reassigned_email(issue)
@ -16,5 +17,4 @@ class IssueObserver < ActiveRecord::Observer
Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was)
end
end
end