aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test/base_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-05-04 19:36:26 +0200
committerXavier Noria <fxn@hashref.com>2010-05-04 19:36:26 +0200
commit583b60d109522907020700225f1c739737297a2d (patch)
treea36d986cbbb73c94d217cbe86c9af7ef97a89567 /actionmailer/test/base_test.rb
parent44a98967676492995d19fd4d541dbc9d52bf6b53 (diff)
parent0dd3b4630fea4bd4d4010b7096c9ee79d34c4501 (diff)
downloadrails-583b60d109522907020700225f1c739737297a2d.tar.gz
rails-583b60d109522907020700225f1c739737297a2d.tar.bz2
rails-583b60d109522907020700225f1c739737297a2d.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'actionmailer/test/base_test.rb')
-rw-r--r--actionmailer/test/base_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 8e69073009..5506d62d6a 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -113,6 +113,23 @@ 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 },
+ :subject => Proc.new { give_a_greeting }
+
+ def welcome
+ mail
+ end
+
+ private
+
+ def give_a_greeting
+ "Thanks for signing up this afternoon"
+ end
+
+ end
test "method call to mail does not raise error" do
assert_nothing_raised { BaseMailer.welcome }
@@ -560,6 +577,19 @@ 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
+
+ test "we can call other defined methods on the class as needed" do
+ mail = ProcMailer.welcome
+ assert_equal("Thanks for signing up this afternoon", mail.subject)
+ end
protected