aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2009-12-17 11:24:02 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2009-12-17 11:24:02 +1100
commit186cd7bc530f705b889c27f3680ab48c7c10a6f3 (patch)
tree76955e442615d77ee05ef2a8260c5373e1cac680 /actionmailer/test
parent5f2395041d1578433fa825ed5c6f26a201f2203d (diff)
parentb9d4ceb43c9497fb1c47d8b1e1e6a24a9e157384 (diff)
downloadrails-186cd7bc530f705b889c27f3680ab48c7c10a6f3.tar.gz
rails-186cd7bc530f705b889c27f3680ab48c7c10a6f3.tar.bz2
rails-186cd7bc530f705b889c27f3680ab48c7c10a6f3.zip
Merge branch 'rails'
Conflicts: actionmailer/lib/action_mailer.rb actionmailer/lib/action_mailer/delivery_method/smtp.rb
Diffstat (limited to 'actionmailer/test')
-rw-r--r--actionmailer/test/abstract_unit.rb7
-rw-r--r--actionmailer/test/mail_service_test.rb34
-rw-r--r--actionmailer/test/url_test.rb44
3 files changed, 58 insertions, 27 deletions
diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb
index e84b3b0d23..af6f1bc92e 100644
--- a/actionmailer/test/abstract_unit.rb
+++ b/actionmailer/test/abstract_unit.rb
@@ -1,12 +1,9 @@
-root = File.expand_path('../../..', __FILE__)
begin
- require "#{root}/vendor/gems/environment"
+ require File.expand_path('../../../vendor/gems/environment', __FILE__)
rescue LoadError
- $:.unshift("#{root}/activesupport/lib")
- $:.unshift("#{root}/actionpack/lib")
end
-lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+lib = File.expand_path('../../lib', __FILE__)
$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'rubygems'
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index 7a47a654cd..dd8307a834 100644
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -31,6 +31,18 @@ class TestMailer < ActionMailer::Base
render :text => "Goodbye, Mr. #{recipient}"
end
+ def from_with_name
+ from "System <system@loudthinking.com>"
+ recipients "root@loudthinking.com"
+ body "Nothing to see here."
+ end
+
+ def from_without_name
+ from "system@loudthinking.com"
+ recipients "root@loudthinking.com"
+ body "Nothing to see here."
+ end
+
def cc_bcc(recipient)
recipients recipient
subject "testing bcc/cc"
@@ -514,6 +526,28 @@ class ActionMailerTest < Test::Unit::TestCase
assert_equal expected.encoded, delivered.encoded
end
+ def test_from_without_name_for_smtp
+ ActionMailer::Base.delivery_method = :smtp
+ TestMailer.deliver_from_without_name
+
+ mail = MockSMTP.deliveries.first
+ assert_not_nil mail
+ mail, from, to = mail
+
+ assert_equal 'system@loudthinking.com', from.to_s
+ end
+
+ def test_from_with_name_for_smtp
+ ActionMailer::Base.delivery_method = :smtp
+ TestMailer.deliver_from_with_name
+
+ mail = MockSMTP.deliveries.first
+ assert_not_nil mail
+ mail, from, to = mail
+
+ assert_equal 'system@loudthinking.com', from.to_s
+ end
+
def test_reply_to
expected = new_mail
diff --git a/actionmailer/test/url_test.rb b/actionmailer/test/url_test.rb
index 427833b36c..0e565b95e8 100644
--- a/actionmailer/test/url_test.rb
+++ b/actionmailer/test/url_test.rb
@@ -1,7 +1,9 @@
require 'abstract_unit'
-class TestMailer < ActionMailer::Base
+class WelcomeController < ActionController::Base
+end
+class TestMailer < ActionMailer::Base
default_url_options[:host] = 'www.basecamphq.com'
def signed_up_with_url(recipient)
@@ -52,27 +54,25 @@ class ActionMailerUrlTest < Test::Unit::TestCase
end
def test_signed_up_with_url
- ActionController::Routing.use_controllers! ['welcome'] do
- ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
- map.welcome 'welcome', :controller=>"foo", :action=>"bar"
- end
-
- expected = new_mail
- expected.to = @recipient
- expected.subject = "[Signed up] Welcome #{@recipient}"
- expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n<img alt=\"Somelogo\" src=\"/images/somelogo.png\" />"
- expected.from = "system@loudthinking.com"
- expected.date = Time.local(2004, 12, 12)
-
- created = nil
- assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) }
- assert_not_nil created
- assert_equal expected.encoded, created.encoded
-
- assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) }
- assert_not_nil ActionMailer::Base.deliveries.first
- assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
+ ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+ map.welcome 'welcome', :controller=>"foo", :action=>"bar"
end
+
+ expected = new_mail
+ expected.to = @recipient
+ expected.subject = "[Signed up] Welcome #{@recipient}"
+ expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n<img alt=\"Somelogo\" src=\"/images/somelogo.png\" />"
+ expected.from = "system@loudthinking.com"
+ expected.date = Time.local(2004, 12, 12)
+
+ created = nil
+ assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) }
+ assert_not_nil created
+ assert_equal expected.encoded, created.encoded
+
+ assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) }
+ assert_not_nil ActionMailer::Base.deliveries.first
+ assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
end
end