diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-02-22 12:17:08 +1100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-02-22 09:15:48 +0100 |
commit | cefc136ec332e5e065a2f4dd184d6fec0ea3c2ba (patch) | |
tree | 29e16a141c759f64ba0b909e38cdb68f99628c4c /actionmailer/test | |
parent | a6684eeb786663839cf383ea54b681d429a83177 (diff) | |
download | rails-cefc136ec332e5e065a2f4dd184d6fec0ea3c2ba.tar.gz rails-cefc136ec332e5e065a2f4dd184d6fec0ea3c2ba.tar.bz2 rails-cefc136ec332e5e065a2f4dd184d6fec0ea3c2ba.zip |
Adding options to register observers and interceptors through ActionMailer::Base.register_observer and ActionMailer::Base.register_interceptor. These hook into Mail.register_interceptor and Mail.register_observer. Also bumped Mail requirement to 2.1.3
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 5fc229df09..c1cf1f0157 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -502,6 +502,32 @@ class BaseTest < ActiveSupport::TestCase mail = BaseMailer.welcome_from_another_path(['unknown/invalid', 'another.path/base_mailer']) assert_equal("Welcome from another path", mail.body.encoded) end + + # Before and After hooks + + class MyObserver + def self.delivered_email(mail) + end + end + + test "you can register an observer to the mail object that gets informed on email delivery" do + ActionMailer::Base.register_observer(MyObserver) + mail = BaseMailer.welcome + MyObserver.expects(:delivered_email).with(mail) + mail.deliver + end + + class MyInterceptor + def self.delivering_email(mail) + end + end + + test "you can register an interceptor to the mail object that gets passed the mail object before delivery" do + ActionMailer::Base.register_interceptor(MyInterceptor) + mail = BaseMailer.welcome + MyInterceptor.expects(:delivering_email).with(mail) + mail.deliver + end protected |