diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-05-02 11:30:10 +1000 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-05-02 11:56:08 +0200 |
commit | 08b07b60b6d91a2f7bba5eec1e9b1d26599c578a (patch) | |
tree | b315e94b226abd7485c6e52260a0f70213cbd5e2 /actionmailer/test | |
parent | 256a15c23581865559cc758c2e377cd395cc05b3 (diff) | |
download | rails-08b07b60b6d91a2f7bba5eec1e9b1d26599c578a.tar.gz rails-08b07b60b6d91a2f7bba5eec1e9b1d26599c578a.tar.bz2 rails-08b07b60b6d91a2f7bba5eec1e9b1d26599c578a.zip |
Adding ability to pass proc's to the ActionMailer class default method
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 8e69073009..81e41dc8d4 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -113,6 +113,15 @@ class BaseTest < ActiveSupport::TestCase end end end + + class ProcMailer < ActionMailer::Base + default :to => 'system@test.lindsaar.net', + 'X-Proc-Method' => Proc.new { Time.now.to_i.to_s } + + def welcome + mail + end + end test "method call to mail does not raise error" do assert_nothing_raised { BaseMailer.welcome } @@ -560,6 +569,14 @@ class BaseTest < ActiveSupport::TestCase MyInterceptor.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 + Time.stubs(:now).returns(yesterday) + mail2 = ProcMailer.welcome + assert(mail1['X-Proc-Method'].to_s.to_i > mail2['X-Proc-Method'].to_s.to_i) + end protected |