Permalink
Browse files

publicise ActionMailer::MailHelper.format_paragraph

[#6550 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
1 parent ebe4fa5 commit 8e73e589a8949c8162f81148bb497804fa641e1d @dcrec1 dcrec1 committed with spastorino Mar 9, 2011
Showing with 21 additions and 1 deletion.
  1. +8 −1 actionmailer/lib/action_mailer/mail_helper.rb
  2. +13 −0 actionmailer/test/mail_helper_test.rb
@@ -29,7 +29,14 @@ def attachments
@_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)
@exviva

exviva Mar 9, 2011

Contributor

Should probably be format_paragraph here.

@dcrec1

dcrec1 Mar 9, 2011

Contributor

Yes, sorry for the tipo, will fix it.

@dcrec1

dcrec1 Mar 9, 2011

Contributor

my hero 0/

+ # # => " Here is a sample text with\n more than 40 characters"
def format_paragraph(text, len = 72, indent = 2)
sentences = [[]]
@@ -14,6 +14,14 @@ def use_mail_helper
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 @@ def test_use_message
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

0 comments on commit 8e73e58

Please sign in to comment.