diff options
author | Gonçalo Silva <goncalossilva@gmail.com> | 2011-04-17 17:08:49 +0100 |
---|---|---|
committer | Gonçalo Silva <goncalossilva@gmail.com> | 2011-04-17 17:08:49 +0100 |
commit | 1c2b2233c3a7ec76c0a0eddf5b8be45c489be133 (patch) | |
tree | 56f2b767c3a4f1f14c51606bf2cbb714a98c5f89 /actionmailer/test/base_test.rb | |
parent | 8d558cb1b069410c8f693295c9c4e2ffc9661e06 (diff) | |
parent | b6843f22ac42b503f6b8ac00105ca0679049be7d (diff) | |
download | rails-1c2b2233c3a7ec76c0a0eddf5b8be45c489be133.tar.gz rails-1c2b2233c3a7ec76c0a0eddf5b8be45c489be133.tar.bz2 rails-1c2b2233c3a7ec76c0a0eddf5b8be45c489be133.zip |
Merge branch 'master' of https://github.com/rails/rails into performance_test
Diffstat (limited to 'actionmailer/test/base_test.rb')
-rw-r--r-- | actionmailer/test/base_test.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 6a7931da8c..9fdd0e1ced 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -478,6 +478,11 @@ class BaseTest < ActiveSupport::TestCase end end + class MySecondObserver + 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 @@ -485,11 +490,31 @@ class BaseTest < ActiveSupport::TestCase mail.deliver end + test "you can register an observer using its stringified name to the mail object that gets informed on email delivery" do + ActionMailer::Base.register_observer("BaseTest::MyObserver") + mail = BaseMailer.welcome + MyObserver.expects(:delivered_email).with(mail) + mail.deliver + end + + test "you can register multiple observers to the mail object that both get informed on email delivery" do + ActionMailer::Base.register_observers("BaseTest::MyObserver", MySecondObserver) + mail = BaseMailer.welcome + MyObserver.expects(:delivered_email).with(mail) + MySecondObserver.expects(:delivered_email).with(mail) + mail.deliver + end + class MyInterceptor def self.delivering_email(mail) end end + class MySecondInterceptor + 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 @@ -497,6 +522,21 @@ class BaseTest < ActiveSupport::TestCase mail.deliver end + test "you can register an interceptor using its stringified name to the mail object that gets passed the mail object before delivery" do + ActionMailer::Base.register_interceptor("BaseTest::MyInterceptor") + mail = BaseMailer.welcome + MyInterceptor.expects(:delivering_email).with(mail) + mail.deliver + end + + test "you can register multiple interceptors to the mail object that both get passed the mail object before delivery" do + ActionMailer::Base.register_interceptors("BaseTest::MyInterceptor", MySecondInterceptor) + mail = BaseMailer.welcome + MyInterceptor.expects(:delivering_email).with(mail) + MySecondInterceptor.expects(:delivering_email).with(mail) + mail.deliver + end + test "being able to put proc's into the defaults hash and they get evaluated on mail sending" do mail1 = ProcMailer.welcome yesterday = 1.day.ago |