Skip to content

Commit

Permalink
Adding extra spec for attachment order
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel committed Sep 11, 2010
1 parent df29376 commit f341eb8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/mail/body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def sort_parts!
@parts.sort!(@part_sort_order)
p.body.sort_parts!
end
# @parts.sort!(@part_sort_order)
end

# Returns the raw source that the body was initialized with, without
Expand Down
31 changes: 31 additions & 0 deletions spec/mail/attachments_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,34 @@ def check_decoded(actual, expected)

end
end

describe "attachment order" do
it "should be preserved instead when content type exists" do
mail = Mail.new do
to "aaaa@aaaa.aaa"
from "aaaa2@aaaa.aaa"
subject "a subject"
date Time.now
text_part do
content_type 'text/plain; charset=UTF-8'
body "a \nsimplebody\n"
end
end

mail.attachments['test.zip'] = File.read(fixture('attachments', 'test.zip'))
mail.attachments['test.pdf'] = File.read(fixture('attachments', 'test.pdf'))
mail.attachments['test.gif'] = File.read(fixture('attachments', 'test.gif'))
mail.attachments['test.jpg'] = File.read(fixture('attachments', 'test.jpg'))
mail.attachments[0].filename.should == 'test.zip'
mail.attachments[1].filename.should == 'test.pdf'
mail.attachments[2].filename.should == 'test.gif'
mail.attachments[3].filename.should == 'test.jpg'


mail2 = Mail.new(mail.encoded)
mail2.attachments[0].filename.should == 'test.zip'
mail2.attachments[1].filename.should == 'test.pdf'
mail2.attachments[2].filename.should == 'test.gif'
mail2.attachments[3].filename.should == 'test.jpg'
end
end
2 changes: 1 addition & 1 deletion spec/mail/body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
body.parts.length.should == 1
body.should be_multipart
end

it "should allow you to sort the parts" do
body = Mail::Body.new('')
body << Mail::Part.new("content-type: text/html\r\nsubject: HTML")
Expand Down

0 comments on commit f341eb8

Please sign in to comment.