aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorAlexey Vakhov <vakhov@gmail.com>2012-02-15 10:04:27 +0400
committerAlexey Vakhov <vakhov@gmail.com>2012-02-15 12:09:00 +0400
commit7f33a44ecdcc2960b33fe24e66f463fc5bfff136 (patch)
tree373025c1d6179f8091d15cca3fe80278a7e7b336 /actionmailer
parent1c75b9afa0f2c5fe5e841103e7d7351a89e5873d (diff)
downloadrails-7f33a44ecdcc2960b33fe24e66f463fc5bfff136.tar.gz
rails-7f33a44ecdcc2960b33fe24e66f463fc5bfff136.tar.bz2
rails-7f33a44ecdcc2960b33fe24e66f463fc5bfff136.zip
Fix AM format_paragraph helper method if a first word is long
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/lib/action_mailer/mail_helper.rb2
-rw-r--r--actionmailer/test/mail_helper_test.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/actionmailer/lib/action_mailer/mail_helper.rb b/actionmailer/lib/action_mailer/mail_helper.rb
index 869c4dff4c..72314d81ad 100644
--- a/actionmailer/lib/action_mailer/mail_helper.rb
+++ b/actionmailer/lib/action_mailer/mail_helper.rb
@@ -41,7 +41,7 @@ module ActionMailer
sentences = [[]]
text.split.each do |word|
- if (sentences.last + [word]).join(' ').length > len
+ if sentences.first.present? && (sentences.last + [word]).join(' ').length > len
sentences << [word]
else
sentences.last << word
diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb
index 158a48e995..d8a73e6c46 100644
--- a/actionmailer/test/mail_helper_test.rb
+++ b/actionmailer/test/mail_helper_test.rb
@@ -22,6 +22,14 @@ class HelperMailer < ActionMailer::Base
end
end
+ def use_format_paragraph_with_long_first_word
+ @text = "Antidisestablishmentarianism is very long."
+
+ mail_with_defaults do |format|
+ format.html { render(:inline => "<%= format_paragraph @text, 10, 1 %>") }
+ end
+ end
+
def use_mailer
mail_with_defaults do |format|
format.html { render(:inline => "<%= mailer.message.subject %>") }
@@ -81,6 +89,11 @@ class MailerHelperTest < ActionMailer::TestCase
assert_match " But soft! What\r\n light through\r\n yonder window\r\n breaks?", mail.body.encoded
end
+ def test_use_format_paragraph_with_long_first_word
+ mail = HelperMailer.use_format_paragraph_with_long_first_word
+ assert_equal " Antidisestablishmentarianism\r\n is very\r\n long.", mail.body.encoded
+ end
+
def test_use_block_format
mail = HelperMailer.use_block_format
expected = <<-TEXT