diff options
author | Grant Hollingworth <grant@antiflux.org> | 2008-11-05 22:54:37 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-06 13:07:16 +0100 |
commit | 732c724df61bc8b780dc42817625b25a321908e4 (patch) | |
tree | c444d2594fc1bc6f3888d9eeb61b6b8417959d58 /actionmailer/test | |
parent | 6406a87eedb74a41f19f5ad21ea1b8f97dd45755 (diff) | |
download | rails-732c724df61bc8b780dc42817625b25a321908e4.tar.gz rails-732c724df61bc8b780dc42817625b25a321908e4.tar.bz2 rails-732c724df61bc8b780dc42817625b25a321908e4.zip |
Turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it [#1336 state:committed]
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/abstract_unit.rb | 8 | ||||
-rw-r--r-- | actionmailer/test/mail_service_test.rb | 14 |
2 files changed, 20 insertions, 2 deletions
diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 905f25c9f7..1617b88c8e 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -24,11 +24,15 @@ class MockSMTP def sendmail(mail, from, to) @@deliveries << [mail, from, to] end + + def start(*args) + yield self + end end class Net::SMTP - def self.start(*args) - yield MockSMTP.new + def self.new(*args) + MockSMTP.new end end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 7f9540c44b..f5cb372b2a 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -938,6 +938,20 @@ EOF mail = TestMailer.create_body_ivar(@recipient) assert_equal "body: foo\nbar: baz", mail.body end + + def test_starttls_is_enabled_if_supported + MockSMTP.any_instance.expects(:respond_to?).with(:enable_starttls_auto).returns(true) + MockSMTP.any_instance.expects(:enable_starttls_auto) + ActionMailer::Base.delivery_method = :smtp + TestMailer.deliver_signed_up(@recipient) + end + + def test_starttls_is_disabled_if_not_supported + MockSMTP.any_instance.expects(:respond_to?).with(:enable_starttls_auto).returns(false) + MockSMTP.any_instance.expects(:enable_starttls_auto).never + ActionMailer::Base.delivery_method = :smtp + TestMailer.deliver_signed_up(@recipient) + end end end # uses_mocha |