Skip to content

Commit

Permalink
* Closed #18516 - Fix TMail::Mail#preamble, and add #preamble= (Charl…
Browse files Browse the repository at this point in the history
…es Lowe)
  • Loading branch information
mikel committed Mar 1, 2008
1 parent 8567557 commit 2ca2caa
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/tmail/mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,12 @@ def each( &block )
end

def quoted_body
parse_body
@body_port.ropen {|f|
return f.read
}
body_port.ropen {|f| return f.read }
end

def quoted_body= str
body_port.wopen { |f| f.write str }
str
end

def body=( str )
Expand All @@ -477,8 +479,8 @@ def body=( str )
str
end

alias preamble body
alias preamble= body=
alias preamble quoted_body
alias preamble= quoted_body=

def epilogue
parse_body
Expand Down
5 changes: 5 additions & 0 deletions log/BugTrackingLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
== Sat Mar 1 23:34:40 GMT 2008 Mikel Lindsaar <raasdnil@gmail.com>

* Closed #18516 - Fix TMail::Mail#preamble, and add #preamble= (Charles Lowe)
* Closed #18515 - Removed ftools from test case (Charles Lowe)

== Fri Feb 22 15:28:16 GMT 2008 Mikel Lindsaar <raasdnil@gmail.com>

* A _LOT_ more documentation, almost ready for the next release
Expand Down
26 changes: 26 additions & 0 deletions test/test_mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -714,4 +714,30 @@ def test_nested_attachments_are_recognized_correctly
assert_equal "application/pkcs7-signature", mail.attachments.last.content_type
end

def test_preamble_read
fixture = File.read("#{File.dirname(__FILE__)}/fixtures/raw_email4")
mail = TMail::Mail.parse(fixture)
assert_equal 'This is a multi-part message in MIME format.', mail.preamble.strip
end

def test_preamble_write
mail = TMail::Mail.new
part = TMail::Mail.parse("Content-Type: text/plain\n\nBlah")
mail.parts << part
mail.preamble = 'This is the preamble'
# normalize the boundary to something non-random to assert against
str = mail.encoded
result = str.gsub(str[/boundary="(.*?)"/, 1], 'boundary')
expected =<<EOF
Content-Type: multipart/mixed; boundary="boundary"
This is the preamble
--boundary
Content-Type: text/plain
Blah
--boundary--
EOF
assert_equal(crlf(expected), result)
end
end

0 comments on commit 2ca2caa

Please sign in to comment.