From ace74974cf3575bbd3bf7ff4d8a83c3100fd22a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim=20and=20Mikel=20Lindsaar?= Date: Mon, 25 Jan 2010 21:47:03 +1100 Subject: Got AM working with Mail yield on delivery_handler and updated tests --- actionmailer/test/base_test.rb | 7 +++++++ actionmailer/test/delivery_methods_test.rb | 4 ++-- actionmailer/test/old_base/mail_service_test.rb | 8 ++++++++ actionmailer/test/old_base/url_test.rb | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 81e1df3911..0705f22df8 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -363,6 +363,13 @@ class BaseTest < ActiveSupport::TestCase BaseMailer.welcome.deliver assert_equal(1, BaseMailer.deliveries.length) end + + test "calling deliver, ActionMailer should yield back to mail to let it call :do_delivery on itself" do + mail = Mail::Message.new + mail.expects(:do_delivery).once + BaseMailer.expects(:welcome).returns(mail) + BaseMailer.welcome.deliver + end protected diff --git a/actionmailer/test/delivery_methods_test.rb b/actionmailer/test/delivery_methods_test.rb index e70e8acd9b..4907ca0903 100644 --- a/actionmailer/test/delivery_methods_test.rb +++ b/actionmailer/test/delivery_methods_test.rb @@ -159,12 +159,12 @@ class MailDeliveryTest < ActiveSupport::TestCase end end - test "increments the deliveries collection on bogus deliveries if set to ignore" do + test "does not increment the deliveries collection on bogus deliveries" do DeliveryMailer.delivery_method = BogusDelivery DeliveryMailer.raise_delivery_errors = false DeliveryMailer.deliveries.clear DeliveryMailer.welcome.deliver - assert_equal(1, DeliveryMailer.deliveries.length) + assert_equal(0, DeliveryMailer.deliveries.length) end end \ No newline at end of file diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb index 2e33abf9d6..fb784328bc 100644 --- a/actionmailer/test/old_base/mail_service_test.rb +++ b/actionmailer/test/old_base/mail_service_test.rb @@ -387,6 +387,8 @@ class ActionMailerTest < Test::Unit::TestCase end def test_signed_up + TestMailer.delivery_method = :test + Time.stubs(:now => Time.now) expected = new_mail @@ -533,6 +535,8 @@ class ActionMailerTest < Test::Unit::TestCase end def test_reply_to + TestMailer.delivery_method = :test + expected = new_mail expected.to = @recipient @@ -567,6 +571,8 @@ class ActionMailerTest < Test::Unit::TestCase end def test_iso_charset + TestMailer.delivery_method = :test + expected = new_mail( "iso-8859-1" ) expected.to = @recipient expected.subject = encode "testing isø charsets", "iso-8859-1" @@ -601,6 +607,7 @@ class ActionMailerTest < Test::Unit::TestCase end def test_unencoded_subject + TestMailer.delivery_method = :test expected = new_mail expected.to = @recipient expected.subject = "testing unencoded subject" @@ -1029,6 +1036,7 @@ EOF end def test_with_mail_object_deliver + TestMailer.delivery_method = :test mail = TestMailer.headers_with_nonalpha_chars(@recipient) assert_nothing_raised { mail.deliver } assert_equal 1, TestMailer.deliveries.length diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb index 10b6a36efd..5affb47997 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/old_base/url_test.rb @@ -54,6 +54,8 @@ class ActionMailerUrlTest < Test::Unit::TestCase end def test_signed_up_with_url + TestMailer.delivery_method = :test + ActionController::Routing::Routes.draw do |map| map.connect ':controller/:action/:id' map.welcome 'welcome', :controller=>"foo", :action=>"bar" -- cgit v1.2.3