Skip to content

Commit c520504

Browse files
Use right option for excerpt text helper in tests, fix build
`excerpt` text helper uses `:radius`, not `line_width` (that is used by `word_wrap` helper). Also cleanup some whitespaces.
1 parent 879611f commit c520504

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

actionpack/lib/action_view/helpers/text_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def highlight(text, phrases, *args)
113113
unless args.empty?
114114
ActiveSupport::Deprecation.warn "Calling highlight with a highlighter as an argument is deprecated. " \
115115
"Please call with :highlighter => '#{args[0]}' instead.", caller
116-
116+
117117
options[:highlighter] = args[0] || '<strong class="highlight">\1</strong>'
118118
end
119119
options.reverse_merge!(:highlighter => '<strong class="highlight">\1</strong>')
@@ -161,7 +161,7 @@ def excerpt(text, phrase, *args)
161161
unless args.empty?
162162
ActiveSupport::Deprecation.warn "Calling excerpt with radius and omission as arguments is deprecated. " \
163163
"Please call with :radius => #{args[0]}#{", :omission => '#{args[1]}'" if args[1]} instead.", caller
164-
164+
165165
options[:radius] = args[0] || 100
166166
options[:omission] = args[1] || "..."
167167
end

actionpack/test/template/text_helper_test.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ def test_highlight
130130

131131
assert_equal ' ', highlight(' ', 'blank text is returned verbatim')
132132
end
133-
133+
134134
def test_highlight_old_api_is_depcrecated
135135
assert_deprecated("Calling highlight with a highlighter as an argument is deprecated. Please call with :highlighter => '<mark>\\1</mark>' instead.") do
136-
highlight("This is a beautiful morning", "beautiful", '<mark>\1</mark>')
136+
highlight("This is a beautiful morning", "beautiful", '<mark>\1</mark>')
137137
end
138138
end
139139

@@ -205,13 +205,13 @@ def test_excerpt
205205
assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", :radius => 5))
206206
assert_nil excerpt("This is a beautiful morning", "day")
207207
end
208-
208+
209209
def test_excerpt_old_api_is_depcrecated
210210
assert_deprecated("Calling excerpt with radius and omission as arguments is deprecated. Please call with :radius => 5 instead.") do
211-
excerpt("This is a beautiful morning", "morning", 5)
211+
excerpt("This is a beautiful morning", "morning", 5)
212212
end
213213
assert_deprecated("Calling excerpt with radius and omission as arguments is deprecated. Please call with :radius => 5, :omission => 'mor' instead.") do
214-
excerpt("This is a beautiful morning", "morning", 5, "mor")
214+
excerpt("This is a beautiful morning", "morning", 5, "mor")
215215
end
216216
end
217217

@@ -253,10 +253,10 @@ def test_excerpt_with_omission
253253
if RUBY_VERSION < '1.9'
254254
def test_excerpt_with_utf8
255255
with_kcode('u') do
256-
assert_equal("...\357\254\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', :line_width => 8))
256+
assert_equal("...\357\254\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', :radius => 8))
257257
end
258258
with_kcode('none') do
259-
assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', :line_width => 8))
259+
assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', :radius => 8))
260260
end
261261
end
262262
else
@@ -270,7 +270,7 @@ def test_excerpt_with_utf8
270270
def test_word_wrap
271271
assert_equal("my very very\nvery long\nstring", word_wrap("my very very very long string", :line_width => 15))
272272
end
273-
273+
274274
def test_word_wrap_old_api_is_depcrecated
275275
assert_deprecated("Calling word_wrap with line_width as an argument is deprecated. Please call with :line_width => 15 instead.") do
276276
word_wrap("my very very very long string", 15)

0 commit comments

Comments
 (0)