File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1778,7 +1778,7 @@ def add_file(values)
1778
1778
private_constant :MULTIPART_CONVERSION_CONTENT_FIELDS if respond_to? ( :private_constant )
1779
1779
1780
1780
def convert_to_multipart
1781
- text_part = Mail ::Part . new ( :body => body . decoded )
1781
+ text_part = Mail ::Part . new ( :content_type => 'text/plain;' , : body => body . decoded )
1782
1782
1783
1783
MULTIPART_CONVERSION_CONTENT_FIELDS . each do |field_name |
1784
1784
if value = send ( field_name )
Original file line number Diff line number Diff line change @@ -1507,6 +1507,28 @@ def message_headers_should_match(message, other)
1507
1507
end
1508
1508
end
1509
1509
1510
+ describe "add_file sets content_type from attachment" do
1511
+ it "should work if set before body" do
1512
+ m = Mail . new
1513
+ m . add_file :filename => 'a.txt' , :content => 'b'
1514
+ m . body 'c'
1515
+ expect ( m . parts . first . content_type ) . to match ( /text\/ plain/ )
1516
+ expect ( m . parts . first . body . encoded ) . to eq ( 'b' )
1517
+ expect ( m . parts . last . content_type ) . to match ( /text\/ plain/ )
1518
+ expect ( m . parts . last . body . encoded ) . to eq ( 'c' )
1519
+ end
1520
+
1521
+ it "should work if set after body" do
1522
+ m = Mail . new
1523
+ m . body 'c'
1524
+ m . add_file :filename => 'a.txt' , :content => 'b'
1525
+ expect ( m . parts . first . content_type ) . to match ( /text\/ plain/ )
1526
+ expect ( m . parts . first . body . encoded ) . to eq ( 'c' )
1527
+ expect ( m . parts . last . content_type ) . to match ( /text\/ plain/ )
1528
+ expect ( m . parts . last . body . encoded ) . to eq ( 'b' )
1529
+ end
1530
+ end
1531
+
1510
1532
describe "content-transfer-encoding" do
1511
1533
1512
1534
it "should use 7bit for only US-ASCII chars" do
You can’t perform that action at this time.
0 commit comments