Make TMail::Mail#has_attachments? use logic from #attachment? (closes #3815) [devslashnull@gmail.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3652 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2006-02-25 23:38:48 +00:00
parent 5e99422d61
commit 4bd80f110d
2 changed files with 2 additions and 1 deletions

View File

@@ -7,7 +7,7 @@ module TMail
class Mail
def has_attachments?
multipart? && parts.any? { |part| part.header["content-type"].main_type != "text" }
multipart? && parts.any? { |part| attachment?(part) }
end
def attachment?(part)

View File

@@ -590,6 +590,7 @@ EOF
def test_attachment_with_text_type
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email13")
mail = TMail::Mail.parse(fixture)
assert mail.has_attachments?
assert_equal 1, mail.attachments.length
assert_equal "hello.rb", mail.attachments.first.original_filename
end