Safecast/teamdata — pull request #47 by rknLA (2012-10-30 23:43:33+00:00)
Title: Digest admin email

Addresses https://github.com/Safecast/teamdata/issues/45

The idea is that the DigestEmailer is a sort of singleton.

Each import that's uploaded gets added to the current digest. If no current digest exists, one is created with a send date 24 hours in the future, and then the import is added. Imports uploaded within that window get added as expected.

Worst case scenario is that it takes 24 hours for a single import approval email to propagate. Best case, there are a handful of imports in one email.

Testing is a bit minimal, since it's not really clear to me how to test the emailing mechanism when it's scheduled for the future (`Delayed::Worker.new.work_off` doesn't do anything if the job is scheduled for 1 day from now unless I let the test run for a day).

We may also run into a bug where calling `.deliver` on a notification mailer inside a delayed job could cause it to send twice. The example case is when `.delay` is used in the method call chain, so it's not clear if we'll see that symptom until we actually start sending email through this process.

@paulca please review and comment.