Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow string as delivery_method #461

Merged
merged 1 commit into from
Nov 17, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mail/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def delivery_method(method = nil, settings = {})
end

def lookup_delivery_method(method)
case method
case method.is_a?(String) ? method.to_sym : method
when nil
Mail::SMTP
when :smtp
Expand Down
11 changes: 11 additions & 0 deletions spec/mail/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def initialize(values)

describe "network configurations" do

it "defaults delivery_method to smtp" do
Mail.defaults { delivery_method nil, { :address => 'some.host' } }
Mail.delivery_method.settings[:address].should eq 'some.host'
end

it "should be available from the Mail.defaults method" do
Mail.defaults { delivery_method :smtp, { :address => 'some.host' } }
Mail.delivery_method.settings[:address].should eq 'some.host'
Expand All @@ -23,6 +28,12 @@ def initialize(values)
Mail.delivery_method.settings[:location].should eq "/usr/bin/sendmail"
end

it "should configure sendmail using a string" do
Mail.defaults { delivery_method 'sendmail', :location => "/usr/bin/sendmail" }
Mail.delivery_method.class.should eq Mail::Sendmail
Mail.delivery_method.settings[:location].should eq "/usr/bin/sendmail"
end

it "should configure exim" do
Mail.defaults { delivery_method :exim, :location => "/usr/bin/exim" }
Mail.delivery_method.class.should eq Mail::Exim
Expand Down