aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/lib/action_mailer/base.rb36
-rw-r--r--actionmailer/test/mail_service_test.rb9
2 files changed, 32 insertions, 13 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 082560e695..5ece35e69b 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -367,7 +367,29 @@ module ActionMailer #:nodoc:
# Mail uses the same defaults as Rails, except for the file delivery method
# save location so we just add this here.
def delivery_settings
- @delivery_settings ||= {:file => {:location => defined?(Rails.root) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"}}
+ @@delivery_settings ||= begin
+ hash = Hash.new { |h,k| h[k] = {} }
+ hash[:file] = {
+ :location => defined?(Rails.root) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
+ }
+
+ hash[:smtp] = {
+ :address => "localhost",
+ :port => 25,
+ :domain => 'localhost.localdomain',
+ :user_name => nil,
+ :password => nil,
+ :authentication => nil,
+ :enable_starttls_auto => true
+ }
+
+ hash[:sendmail] = {
+ :location => '/usr/sbin/sendmail',
+ :arguments => '-i -t'
+ }
+
+ hash
+ end
end
alias :controller_path :mailer_name
@@ -386,7 +408,11 @@ module ActionMailer #:nodoc:
end
elsif match = matches_settings_method?(method_symbol)
# TODO Deprecation warning
- delivery_settings[match[1].to_sym] = parameters[0]
+ if match[2]
+ delivery_settings[match[1].to_sym] = parameters[0]
+ else
+ delivery_settings[match[1].to_sym]
+ end
else
super
end
@@ -461,13 +487,11 @@ module ActionMailer #:nodoc:
private
def get_delivery_settings(method) #:nodoc:
- method.is_a?(Symbol) ? delivery_settings[method] : delivery_settings[:custom]
+ delivery_settings[method]
end
def matches_settings_method?(method_name) #:nodoc:
- method_name = method_name.to_s
- delivery_method.is_a?(Symbol) ? method = delivery_method : method = :custom
- /(file|sendmail|smtp)_settings$/.match(method_name)
+ /(\w+)_settings(=)?$/.match(method_name.to_s)
end
def matches_dynamic_method?(method_name) #:nodoc:
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index 17e7992e29..7b5f8b1ffc 100644
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -680,7 +680,7 @@ class ActionMailerTest < Test::Unit::TestCase
def test_performs_delivery_via_sendmail
IO.expects(:popen).once.with('/usr/sbin/sendmail -i -t test@localhost', 'w+')
- TestMailer.delivery_method = :sendmail
+ ActionMailer::Base.delivery_method = :sendmail
TestMailer.deliver_signed_up(@recipient)
end
@@ -1069,12 +1069,7 @@ EOF
def test_return_path_with_create
mail = TestMailer.create_return_path
- assert_equal "another@somewhere.test", mail['return-path'].to_s
- end
-
- def test_return_path_with_create
- mail = TestMailer.create_return_path
- assert_equal ["another@somewhere.test"], mail.return_path
+ assert_equal "another@somewhere.test", mail.return_path
end
def test_return_path_with_deliver