mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Define a welcome controller in mailer tests
This commit is contained in:
parent
075f50d62c
commit
6ac32a8328
1 changed files with 22 additions and 22 deletions
|
@ -1,7 +1,9 @@
|
||||||
require 'abstract_unit'
|
require 'abstract_unit'
|
||||||
|
|
||||||
class TestMailer < ActionMailer::Base
|
class WelcomeController < ActionController::Base
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestMailer < ActionMailer::Base
|
||||||
default_url_options[:host] = 'www.basecamphq.com'
|
default_url_options[:host] = 'www.basecamphq.com'
|
||||||
|
|
||||||
def signed_up_with_url(recipient)
|
def signed_up_with_url(recipient)
|
||||||
|
@ -52,27 +54,25 @@ class ActionMailerUrlTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_signed_up_with_url
|
def test_signed_up_with_url
|
||||||
ActionController::Routing.use_controllers! ['welcome'] do
|
ActionController::Routing::Routes.draw do |map|
|
||||||
ActionController::Routing::Routes.draw do |map|
|
map.connect ':controller/:action/:id'
|
||||||
map.connect ':controller/:action/:id'
|
map.welcome 'welcome', :controller=>"foo", :action=>"bar"
|
||||||
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
|
||||||
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue