2008-01-05 08:32:22 -05:00
|
|
|
require 'abstract_unit'
|
2007-11-07 11:05:17 -05:00
|
|
|
|
|
|
|
class DefaultDeliveryMethodMailer < ActionMailer::Base
|
|
|
|
end
|
|
|
|
|
|
|
|
class NonDefaultDeliveryMethodMailer < ActionMailer::Base
|
|
|
|
self.delivery_method = :sendmail
|
|
|
|
end
|
|
|
|
|
2009-08-07 23:56:54 -04:00
|
|
|
class FileDeliveryMethodMailer < ActionMailer::Base
|
|
|
|
self.delivery_method = :file
|
|
|
|
end
|
|
|
|
|
2009-10-28 05:17:59 -04:00
|
|
|
class CustomDeliveryMethod
|
|
|
|
attr_accessor :custom_deliveries
|
|
|
|
def initialize()
|
|
|
|
@customer_deliveries = []
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.perform_delivery(mail)
|
|
|
|
self.custom_deliveries << mail
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class CustomerDeliveryMailer < ActionMailer::Base
|
|
|
|
self.delivery_method = CustomDeliveryMethod.new
|
|
|
|
end
|
|
|
|
|
2007-11-07 11:05:17 -05:00
|
|
|
class ActionMailerBase_delivery_method_Test < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
set_delivery_method :smtp
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
restore_delivery_method
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_be_the_default_smtp
|
2009-10-28 05:17:59 -04:00
|
|
|
assert_instance_of ActionMailer::DeliveryMethod::Smtp, ActionMailer::Base.delivery_method
|
2007-11-07 11:05:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class DefaultDeliveryMethodMailer_delivery_method_Test < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
set_delivery_method :smtp
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
restore_delivery_method
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_be_the_default_smtp
|
2009-10-28 05:17:59 -04:00
|
|
|
assert_instance_of ActionMailer::DeliveryMethod::Smtp, DefaultDeliveryMethodMailer.delivery_method
|
2007-11-07 11:05:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class NonDefaultDeliveryMethodMailer_delivery_method_Test < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
set_delivery_method :smtp
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
restore_delivery_method
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_be_the_set_delivery_method
|
2009-10-28 05:17:59 -04:00
|
|
|
assert_instance_of ActionMailer::DeliveryMethod::Sendmail, NonDefaultDeliveryMethodMailer.delivery_method
|
2007-11-07 11:05:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-08-07 23:56:54 -04:00
|
|
|
class FileDeliveryMethodMailer_delivery_method_Test < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
set_delivery_method :smtp
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
restore_delivery_method
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_be_the_set_delivery_method
|
2009-10-28 05:17:59 -04:00
|
|
|
assert_instance_of ActionMailer::DeliveryMethod::File, FileDeliveryMethodMailer.delivery_method
|
2009-08-07 23:56:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_default_location_to_the_tmpdir
|
|
|
|
assert_equal "#{Dir.tmpdir}/mails", ActionMailer::Base.file_settings[:location]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-10-28 05:17:59 -04:00
|
|
|
class CustomDeliveryMethodMailer_delivery_method_Test < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
set_delivery_method :smtp
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
restore_delivery_method
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_be_the_set_delivery_method
|
|
|
|
assert_instance_of CustomDeliveryMethod, CustomerDeliveryMailer.delivery_method
|
|
|
|
end
|
|
|
|
end
|