Separate observing of Note and MergeRequests

* Move is_assigned? and is_being_xx? methods to IssueCommonality

  This is behavior merge requests have in common with issues. Moved
  methods to IssueCommonality role. Put specs directly into
  merge_request_spec because setup differs for issues and MRs
  specifically in the "closed" factory to use.

* Add MergeRequestObserver. Parallels IssueObserver in almost every way.

  Ripe for refactoring.

* Rename MailerObserver to NoteObserver

  With merge request observing moved out of MailerObserver, all that
  was left was Note logic. Renamed to NoteObserver, added tests and
  updated application config for new observer names. Refactored
  NoteObserver to use the note's author and not rely on current_user.

* Set current_user for MergeRequestObserver

  IssueObserver and MergeRequestObserver are the only observers that
  need a reference to the current_user that they cannot look up on
  the objects they are observing.
This commit is contained in:
Robb Kidd 2012-10-09 18:25:29 -04:00
parent 2b7fd29b1a
commit 16ceae895e
11 changed files with 445 additions and 102 deletions

View file

@ -1,7 +1,6 @@
class ApplicationController < ActionController::Base
before_filter :authenticate_user!
before_filter :reject_blocked!
before_filter :set_current_user_for_mailer
before_filter :set_current_user_for_observers
before_filter :dev_tools if Rails.env == 'development'
@ -41,11 +40,8 @@ class ApplicationController < ActionController::Base
end
end
def set_current_user_for_mailer
MailerObserver.current_user = current_user
end
def set_current_user_for_observers
MergeRequestObserver.current_user = current_user
IssueObserver.current_user = current_user
end