1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionmailer/test/delivery_method_test.rb

74 lines
2.1 KiB
Ruby
Raw Normal View History

require 'abstract_unit'
2010-01-16 06:10:11 -05:00
require 'mail'
2010-01-19 09:34:58 -05:00
class MyCustomDelivery
end
2010-01-19 09:34:58 -05:00
class DefaultsDeliveryMethodsTest < ActionMailer::TestCase
def setup
set_delivery_method :smtp
end
2010-01-19 09:34:58 -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
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
end
end
2010-01-19 09:34:58 -05:00
class CustomDeliveryMethodsTest < ActionMailer::TestCase
def setup
2010-01-19 09:34:58 -05:00
ActionMailer::Base.add_delivery_method :custom, MyCustomDelivery
end
def teardown
2010-01-19 09:34:58 -05:00
ActionMailer::Base.delivery_methods.delete(:custom)
ActionMailer::Base.delivery_settings.delete(:custom)
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
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
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
end
end