Permalink
Browse files

small smtp change to support ruby 1.8.7 (and up, hopefully)

  • Loading branch information...
1 parent b10208a commit 5b6866021cd9a7dc9fbc72c466bb1fda600044ea @rsanheim rsanheim committed Oct 5, 2008
Showing with 21 additions and 1 deletion.
  1. +14 −0 spec/cap_gun_spec.rb
  2. +7 −1 vendor/action_mailer_tls/lib/smtp_tls.rb
View
@@ -87,7 +87,21 @@
capistrano = { :current_release => "/data/foo", :previous_release => "/data/foo", :cap_gun_email_envelope => {:recipients => ["joe@example.com"]} }
CapGun::Mailer.any_instance.expects(:create_body).with(capistrano).returns("foo")
CapGun::Mailer.create_deployment_notification capistrano
+ end
+
+ it "calls Net::SMTP to send the mail correctly (we test this because SMTP internals changed between 1.8.6 and newer versions of Ruby)" do
+ ActionMailer::Base.smtp_settings = {
+ :address => "smtp.gmail.com",
+ :port => 587,
+ :domain => "foo.com",
+ :authentication => :plain,
+ :user_name => "username",
+ :password => "password"
+ }
+ capistrano = { :current_release => "/data/foo", :previous_release => "/data/foo", :cap_gun_email_envelope => {:recipients => ["joe@example.com"]} }
+ Net::SMTP.expects(:start)
+ CapGun::Mailer.deliver_deployment_notification capistrano
end
end
@@ -5,7 +5,13 @@
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
- check_auth_args user, secret, authtype if user or secret
+ if user or secret
+ if RUBY_VERSION == "1.8.7"
+ check_auth_args user, secret
+ else
+ check_auth_args user, secret, authtype
+ end
+ end
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)

0 comments on commit 5b68660

Please sign in to comment.