Skip to content

Commit

Permalink
added test of multiple recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
staugaard committed May 27, 2008
1 parent 7e6c879 commit 8689329
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions test/test_idn_actionmailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def signed_up_with_url(recipient)
@sent_on = Time.local(2004, 12, 12)

@body["recipient"] = recipient
@body["welcome_url"] = url_for :host => "example.com", :controller => "welcome", :action => "greeting"
end

class <<self
Expand Down Expand Up @@ -47,15 +46,9 @@ def setup
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []

@recipient = 'bla <mick@brændendekærlighed.dk>'
end

def test_signed_up_with_url
ActionController::Routing::Routes.draw do |map|
map.connect ':controller/:action/:id'
map.welcome 'welcome', :controller=>"foo", :action=>"bar"
end
def test_single_address

expected = new_mail
expected.to = 'bla <mick@xn--brndendekrlighed-vobh.dk>'
Expand All @@ -65,14 +58,26 @@ def test_signed_up_with_url
expected.date = Time.local(2004, 12, 12)

created = nil
assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) }
assert_nothing_raised { created = TestMailer.create_signed_up_with_url('bla <mick@brændendekærlighed.dk>') }
assert_not_nil created
assert_equal expected.encoded, created.encoded

assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) }
assert_nothing_raised { TestMailer.deliver_signed_up_with_url('bla <mick@brændendekærlighed.dk>') }
assert_not_nil ActionMailer::Base.deliveries.first
assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded

puts ActionMailer::Base.deliveries.first
end

def test_multi_addresses
expected = new_mail
expected.to = ['bla <mick@xn--brndendekrlighed-vobh.dk>', 'mick@xn--brndendekrlighed-vobh.dk']
expected.subject = "[Signed up] Welcome"
expected.body = "Hello there"
expected.from = "bla <system@loudthinking.com>"
expected.date = Time.local(2004, 12, 12)

created = nil
assert_nothing_raised { created = TestMailer.create_signed_up_with_url(['bla <mick@brændendekærlighed.dk>', 'mick@brændendekærlighed.dk']) }
assert_not_nil created
assert_equal expected.encoded, created.encoded
end
end

0 comments on commit 8689329

Please sign in to comment.