mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
publicise ActionMailer::MailHelper.format_paragraph
[#6550 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
parent
ebe4fa5fbe
commit
8e73e589a8
2 changed files with 21 additions and 1 deletions
|
@ -29,7 +29,14 @@ module ActionMailer
|
|||
@_message.attachments
|
||||
end
|
||||
|
||||
private
|
||||
# Returns +text+ wrapped at +len+ columns and indented +indent+ spaces.
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# my_text = "Here is a sample text with more than 40 characters"
|
||||
#
|
||||
# simple_format(my_text, 25, 4)
|
||||
# # => " Here is a sample text with\n more than 40 characters"
|
||||
def format_paragraph(text, len = 72, indent = 2)
|
||||
sentences = [[]]
|
||||
|
||||
|
|
|
@ -14,6 +14,14 @@ class HelperMailer < ActionMailer::Base
|
|||
end
|
||||
end
|
||||
|
||||
def use_format_paragraph
|
||||
@text = "But soft! What light through yonder window breaks?"
|
||||
|
||||
mail_with_defaults do |format|
|
||||
format.html { render(:inline => "<%= format_paragraph @text, 15, 1 %>") }
|
||||
end
|
||||
end
|
||||
|
||||
def use_mailer
|
||||
mail_with_defaults do |format|
|
||||
format.html { render(:inline => "<%= mailer.message.subject %>") }
|
||||
|
@ -50,5 +58,10 @@ class MailerHelperTest < ActionMailer::TestCase
|
|||
mail = HelperMailer.use_message
|
||||
assert_match "using helpers", mail.body.encoded
|
||||
end
|
||||
|
||||
def test_use_format_paragraph
|
||||
mail = HelperMailer.use_format_paragraph
|
||||
assert_match " But soft! What\r\n light through\r\n yonder window\r\n breaks?", mail.body.encoded
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue