mhfs/devise-async — pull request #19 by krider2010 (2013-01-07 13:57:05+00:00)
Title: Allow for callbacks to the model on mail actually being sent

(rather than when queued). Also allow for options to be stored as queue parameters for data that may be available when the email is queued, but not when the mail is sent, but should not be properly persisted into the database.

Using this variant with our code and a Resque backend and seeing the desired behaviour. For example on our customer model....

devise ..., :async
...
def mail_options(notification)
{
:extra_param => "request data"
}
end

def devise_mail_sent(method)
if method == :reset_password_instructions
# Log a reset...
end
end

And then in the custom mailer:

class OurMailer < Devise::Mailer
def reset_password_instructions(record, options)
if options.empty? || options.blank?
# Log out warning
else
# Act on options[:extra_param]
end
devise_mail(record, :reset_password_instructions)
end
end

I've added tests where I can though mocha is a little too clever with it's expects/method_missing to allow proper testing of the responds_to? code I've written :(