aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test/base_test.rb
diff options
context:
space:
mode:
authorJosé Valim and Mikel Lindsaar <raasdnil@gmail.com>2010-01-21 20:03:55 +1100
committerJosé Valim and Mikel Lindsaar <raasdnil@gmail.com>2010-01-21 20:03:55 +1100
commit3829f9ecfd6fcd54edbc15f624ee3b68f6dae135 (patch)
treef85c4fb58b38209ddbffc76f8c8e7ad26c4c6945 /actionmailer/test/base_test.rb
parentfbdbac2b88218e5e3e6087c67dacf7e755aa4106 (diff)
downloadrails-3829f9ecfd6fcd54edbc15f624ee3b68f6dae135.tar.gz
rails-3829f9ecfd6fcd54edbc15f624ee3b68f6dae135.tar.bz2
rails-3829f9ecfd6fcd54edbc15f624ee3b68f6dae135.zip
Adding tests for attachments['blah.rb'] = {} et al
Diffstat (limited to 'actionmailer/test/base_test.rb')
-rw-r--r--actionmailer/test/base_test.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index b8d2e46241..f1f5f38482 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -42,12 +42,18 @@ class BaseTest < Test::Unit::TestCase
class TestMailer < ActionMailer::Base
def welcome(hash = {})
- headers['X-SPAM'] = "Not SPAM"
hash = {:to => 'mikel@test.lindsaar.net', :from => 'jose@test.plataformatec.com',
:subject => 'The first email on new API!'}.merge!(hash)
mail(hash)
end
+ def invoice(hash = {})
+ attachments['invoice.pdf'] = 'This is test File content'
+ hash = {:to => 'mikel@test.lindsaar.net', :from => 'jose@test.plataformatec.com',
+ :subject => 'Your invoice is attached'}.merge!(hash)
+ mail(hash)
+ end
+
end
def test_the_method_call_to_mail_does_not_raise_error
@@ -84,6 +90,25 @@ class BaseTest < Test::Unit::TestCase
# assert_equal("Not SPAM", email['X-SPAM'])
# end
+ def test_should_allow_you_to_send_an_attachment
+ assert_nothing_raised { TestMailer.deliver_invoice }
+ end
+
+ def test_should_allow_you_to_send_an_attachment
+ email = TestMailer.deliver_invoice
+ assert_equal(1, email.attachments.length)
+ end
+
+ def test_should_allow_you_to_send_an_attachment
+ email = TestMailer.deliver_invoice
+ assert_equal('invoice.pdf', email.attachments[0].filename)
+ end
+
+ def test_should_allow_you_to_send_an_attachment
+ email = TestMailer.deliver_invoice
+ assert_equal('This is test File content', email.attachments['invoice.pdf'].decoded)
+ end
+
def test_should_use_class_defaults
end