aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-11-14 17:41:25 +0530
committerPratik Naik <pratiknaik@gmail.com>2008-11-14 17:41:25 +0530
commit17b1387646a9537c978e9d7c5f3a68f740cd9377 (patch)
tree81735b97603471bb9780ed0fd133dad7a16f59a7 /actionmailer/test
parentfa9ea057d1252a578f8e056defef41b93853bc8b (diff)
parent549b18c9286b6cccf4978093576325fd711dc421 (diff)
downloadrails-17b1387646a9537c978e9d7c5f3a68f740cd9377.tar.gz
rails-17b1387646a9537c978e9d7c5f3a68f740cd9377.tar.bz2
rails-17b1387646a9537c978e9d7c5f3a68f740cd9377.zip
Merge commit 'mainstream/master'
Conflicts: railties/doc/guides/html/actioncontroller_basics.html railties/doc/guides/html/activerecord_validations_callbacks.html railties/doc/guides/html/debugging_rails_applications.html railties/doc/guides/html/testing_rails_applications.html railties/doc/guides/source/actioncontroller_basics/methods.txt railties/doc/guides/source/actioncontroller_basics/params.txt railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt railties/doc/guides/source/actioncontroller_basics/session.txt railties/doc/guides/source/activerecord_validations_callbacks.txt railties/doc/guides/source/debugging_rails_applications.txt railties/doc/guides/source/testing_rails_applications.txt
Diffstat (limited to 'actionmailer/test')
-rw-r--r--actionmailer/test/abstract_unit.rb8
-rw-r--r--actionmailer/test/mail_service_test.rb26
2 files changed, 32 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..b88beb3314 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
@@ -1031,4 +1045,16 @@ class RespondToTest < Test::Unit::TestCase
def test_should_not_respond_to_deliver_with_template_suffix_if_it_begins_with_a_digit
assert !RespondToMailer.respond_to?(:deliver_1_template)
end
+
+ def test_should_not_respond_to_method_where_deliver_is_not_a_suffix
+ assert !RespondToMailer.respond_to?(:foo_deliver_template)
+ end
+
+ def test_should_still_raise_exception_with_expected_message_when_calling_an_undefined_method
+ error = assert_raises NoMethodError do
+ RespondToMailer.not_a_method
+ end
+
+ assert_match /undefined method.*not_a_method/, error.message
+ end
end