2008-01-05 08:32:22 -05:00
|
|
|
require 'abstract_unit'
|
2010-01-16 06:10:11 -05:00
|
|
|
require 'mail'
|
2007-11-07 11:05:17 -05:00
|
|
|
|
2010-01-19 09:34:58 -05:00
|
|
|
class MyCustomDelivery
|
2007-11-07 11:05:17 -05:00
|
|
|
end
|
|
|
|
|
2010-01-19 09:34:58 -05:00
|
|
|
class DefaultsDeliveryMethodsTest < ActionMailer::TestCase
|
2007-11-07 11:05:17 -05:00
|
|
|
def setup
|
|
|
|
set_delivery_method :smtp
|
|
|
|
end
|
2010-01-19 09:34:58 -05:00
|
|
|
|
2007-11-07 11:05:17 -05:00
|
|
|
def teardown
|
|
|
|
restore_delivery_method
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_be_the_default_smtp
|
2010-01-16 06:10:11 -05:00
|
|
|
assert_equal :smtp, ActionMailer::Base.delivery_method
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_have_default_smtp_delivery_method_settings
|
|
|
|
settings = { :address => "localhost",
|
|
|
|
:port => 25,
|
|
|
|
:domain => 'localhost.localdomain',
|
|
|
|
:user_name => nil,
|
|
|
|
:password => nil,
|
|
|
|
:authentication => nil,
|
|
|
|
:enable_starttls_auto => true }
|
|
|
|
assert_equal settings, ActionMailer::Base.smtp_settings
|
2007-11-07 11:05:17 -05:00
|
|
|
end
|
|
|
|
|
2010-01-19 09:34:58 -05:00
|
|
|
def test_should_have_default_file_delivery_method_settings
|
|
|
|
settings = {:location => "#{Dir.tmpdir}/mails"}
|
|
|
|
assert_equal settings, ActionMailer::Base.file_settings
|
2010-01-16 06:10:11 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_have_default_sendmail_delivery_method_settings
|
|
|
|
settings = {:location => '/usr/sbin/sendmail',
|
|
|
|
:arguments => '-i -t'}
|
2010-01-19 09:34:58 -05:00
|
|
|
assert_equal settings, ActionMailer::Base.sendmail_settings
|
2007-11-07 11:05:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-01-19 09:34:58 -05:00
|
|
|
class CustomDeliveryMethodsTest < ActionMailer::TestCase
|
2009-08-07 23:56:54 -04:00
|
|
|
def setup
|
2010-01-19 09:34:58 -05:00
|
|
|
ActionMailer::Base.add_delivery_method :custom, MyCustomDelivery
|
2009-08-07 23:56:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
2010-01-19 09:34:58 -05:00
|
|
|
ActionMailer::Base.delivery_methods.delete(:custom)
|
|
|
|
ActionMailer::Base.delivery_settings.delete(:custom)
|
2009-08-07 23:56:54 -04:00
|
|
|
end
|
|
|
|
|
2010-01-19 09:34:58 -05:00
|
|
|
def test_allow_to_add_a_custom_delivery_method
|
|
|
|
ActionMailer::Base.delivery_method = :custom
|
|
|
|
assert_equal :custom, ActionMailer::Base.delivery_method
|
2009-10-28 05:17:59 -04:00
|
|
|
end
|
|
|
|
|
2010-01-19 09:34:58 -05:00
|
|
|
def test_allow_to_customize_custom_settings
|
|
|
|
ActionMailer::Base.custom_settings = { :foo => :bar }
|
|
|
|
assert_equal Hash[:foo => :bar], ActionMailer::Base.custom_settings
|
2009-10-28 05:17:59 -04:00
|
|
|
end
|
|
|
|
|
2010-01-19 09:34:58 -05:00
|
|
|
def test_respond_to_custom_method_settings
|
|
|
|
assert_respond_to ActionMailer::Base, :custom_settings
|
|
|
|
assert_respond_to ActionMailer::Base, :custom_settings=
|
2010-01-16 06:10:11 -05:00
|
|
|
end
|
|
|
|
|
2010-01-19 09:34:58 -05:00
|
|
|
def test_should_not_respond_for_invalid_method_settings
|
|
|
|
assert_raise NoMethodError do
|
|
|
|
ActionMailer::Base.another_settings
|
|
|
|
end
|
2009-10-28 05:17:59 -04:00
|
|
|
end
|
|
|
|
end
|