aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test/url_test.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-04 03:24:39 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-04 03:24:39 +0530
commitcda36a0731f14b33a920bf7e32255661e06f890a (patch)
tree79ccba37953f9fe3055503be42b1610faa6d64ad /actionmailer/test/url_test.rb
parentbd4a3cce4ecd8e648179a91e26506e3622ac2162 (diff)
parenta115b5d79a850bb56cd3c9db9a05d6da35e3d7be (diff)
downloadrails-cda36a0731f14b33a920bf7e32255661e06f890a.tar.gz
rails-cda36a0731f14b33a920bf7e32255661e06f890a.tar.bz2
rails-cda36a0731f14b33a920bf7e32255661e06f890a.zip
Merge remote branch 'mainstream/master'
Diffstat (limited to 'actionmailer/test/url_test.rb')
-rw-r--r--actionmailer/test/url_test.rb58
1 files changed, 32 insertions, 26 deletions
diff --git a/actionmailer/test/url_test.rb b/actionmailer/test/url_test.rb
index 2224f6321c..12bf609dce 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)
@@ -10,8 +12,8 @@ class TestMailer < ActionMailer::Base
@from = "system@loudthinking.com"
@sent_on = Time.local(2004, 12, 12)
- @body["recipient"] = recipient
- @body["welcome_url"] = url_for :host => "example.com", :controller => "welcome", :action => "greeting"
+ @recipient = recipient
+ @welcome_url = url_for :host => "example.com", :controller => "welcome", :action => "greeting"
end
class <<self
@@ -31,10 +33,10 @@ class ActionMailerUrlTest < Test::Unit::TestCase
end
def new_mail( charset="utf-8" )
- mail = TMail::Mail.new
+ mail = Mail.new
mail.mime_version = "1.0"
if charset
- mail.set_content_type "text", "plain", { "charset" => charset }
+ mail.content_type ["text", "plain", { "charset" => charset }]
end
mail
end
@@ -52,27 +54,31 @@ 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
+
+ expected.message_id = '<123@456>'
+ created.message_id = '<123@456>'
+ assert_equal expected.encoded, created.encoded
+
+ assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) }
+ assert_not_nil ActionMailer::Base.deliveries.first
+ delivered = ActionMailer::Base.deliveries.first
+
+ delivered.message_id = '<123@456>'
+ assert_equal expected.encoded, delivered.encoded
end
end