aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorDiego Carrion <dc.rec1@gmail.com>2011-03-09 16:06:48 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2011-03-09 18:36:39 -0200
commit8e73e589a8949c8162f81148bb497804fa641e1d (patch)
tree807ad034fa0451d31a70b402d4539f69f3c08788 /actionmailer
parentebe4fa5fbe54cd0559c9e5e58d68326630cfb255 (diff)
downloadrails-8e73e589a8949c8162f81148bb497804fa641e1d.tar.gz
rails-8e73e589a8949c8162f81148bb497804fa641e1d.tar.bz2
rails-8e73e589a8949c8162f81148bb497804fa641e1d.zip
publicise ActionMailer::MailHelper.format_paragraph
[#6550 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/lib/action_mailer/mail_helper.rb9
-rw-r--r--actionmailer/test/mail_helper_test.rb13
2 files changed, 21 insertions, 1 deletions
diff --git a/actionmailer/lib/action_mailer/mail_helper.rb b/actionmailer/lib/action_mailer/mail_helper.rb
index 75901bc431..e708e36369 100644
--- a/actionmailer/lib/action_mailer/mail_helper.rb
+++ b/actionmailer/lib/action_mailer/mail_helper.rb
@@ -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 = [[]]
diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb
index 7cc0804323..17e9c82045 100644
--- a/actionmailer/test/mail_helper_test.rb
+++ b/actionmailer/test/mail_helper_test.rb
@@ -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