Fix e-mail sending on publishing review requests/reviews.

Review Request #994 — Created Aug. 24, 2009 and submitted

chipx86
Review Board
master
reviewboard
Fix e-mail sending on publishing review requests/reviews.

E-mail sending was broken due to a few main issues.

First, reviewboard.notifications wasn't included in the list of installed apps,
meaning that signals were never registered.

Second, the callback signatures weren't really correct for the signals.
They needed to be keyword arguments, rather than standard arguments. This
means they had to have a default value. Set the default value to None and
asserted on the parameters.

Third, we needed a valid sender when emitting the signals, and needed to
set a sender when emitting them. This is required by Django's signal
architecture.

In order to catch issues in the future, I've updated the unit tests to
actually publish the review requests and reviews in order to trigger the
notification and e-mail sending code, rather than forcefully calling the
e-mail sending functions.

Upon doing this, I realized that our signal emitting code was still in the
webapi app, so I've moved this into the appropriate models, guaranteeing
that they will be emitted when publishing, regardless of the codepath.

All this led to one more issue, which is that in unit tests, urls.py isn't
processed. We'd have to manually initialize things. So, I added a
reviewboard.initialize() function that does the main work that urls.py did.
urls.py now just calls initialize(), and the unit tests can call that as
well.

This fixes all the issues I've encountered with e-mail sending since the
big notification restructure.
All new unit tests pass. The server has been updated with this change. There should be an e-mail for this change.
Loading...