diff options
-rw-r--r-- | actionmailer/CHANGELOG | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 4 | ||||
-rwxr-xr-x | actionmailer/test/mail_service_test.rb | 22 |
3 files changed, 26 insertions, 2 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index c876c05333..2942a9c072 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Allow mailer actions named send by using __send__ internally. #6467 [iGEL] + * Add assert_emails and assert_no_emails to test the number of emails delivered. #6479 [Jonathan Viney] # Assert total number of emails delivered: assert_emails 0 diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 444bea95e0..b256016d94 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -369,7 +369,7 @@ module ActionMailer #:nodoc: # rendered and a new TMail::Mail object created. def create!(method_name, *parameters) #:nodoc: initialize_defaults(method_name) - send(method_name, *parameters) + __send__(method_name, *parameters) # If an explicit, textual body has not been set, we check assumptions. unless String === @body @@ -428,7 +428,7 @@ module ActionMailer #:nodoc: logger.info "Sent mail:\n #{mail.encoded}" unless logger.nil? begin - send("perform_delivery_#{delivery_method}", mail) if perform_deliveries + __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries rescue Exception => e # Net::SMTP errors or sendmail pipe errors raise e if raise_delivery_errors end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index ccded61b7c..7b1ec68725 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -801,3 +801,25 @@ class InheritableTemplateRootTest < Test::Unit::TestCase assert_equal expected, FunkyPathMailer.template_root end end + +class MethodNamingTest < Test::Unit::TestCase + class TestMailer < ActionMailer::Base + def send + body 'foo' + end + end + + def setup + ActionMailer::Base.delivery_method = :test + ActionMailer::Base.perform_deliveries = true + ActionMailer::Base.deliveries = [] + end + + def test_send_method + assert_nothing_raised do + assert_emails 1 do + TestMailer.deliver_send + end + end + end +end |