Skip to content

Commit

Permalink
Use right option for excerpt text helper in tests, fix build
Browse files Browse the repository at this point in the history
`excerpt` text helper uses `:radius`, not `line_width` (that is used by
`word_wrap` helper).

Also cleanup some whitespaces.
  • Loading branch information
carlosantoniodasilva committed May 19, 2012
1 parent 879611f commit c520504
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_view/helpers/text_helper.rb
Expand Up @@ -113,7 +113,7 @@ def highlight(text, phrases, *args)
unless args.empty?
ActiveSupport::Deprecation.warn "Calling highlight with a highlighter as an argument is deprecated. " \
"Please call with :highlighter => '#{args[0]}' instead.", caller

options[:highlighter] = args[0] || '<strong class="highlight">\1</strong>'
end
options.reverse_merge!(:highlighter => '<strong class="highlight">\1</strong>')
Expand Down Expand Up @@ -161,7 +161,7 @@ def excerpt(text, phrase, *args)
unless args.empty?
ActiveSupport::Deprecation.warn "Calling excerpt with radius and omission as arguments is deprecated. " \
"Please call with :radius => #{args[0]}#{", :omission => '#{args[1]}'" if args[1]} instead.", caller

options[:radius] = args[0] || 100
options[:omission] = args[1] || "..."
end
Expand Down
16 changes: 8 additions & 8 deletions actionpack/test/template/text_helper_test.rb
Expand Up @@ -130,10 +130,10 @@ def test_highlight

assert_equal ' ', highlight(' ', 'blank text is returned verbatim')
end

def test_highlight_old_api_is_depcrecated
assert_deprecated("Calling highlight with a highlighter as an argument is deprecated. Please call with :highlighter => '<mark>\\1</mark>' instead.") do
highlight("This is a beautiful morning", "beautiful", '<mark>\1</mark>')
highlight("This is a beautiful morning", "beautiful", '<mark>\1</mark>')
end
end

Expand Down Expand Up @@ -205,13 +205,13 @@ def test_excerpt
assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", :radius => 5))
assert_nil excerpt("This is a beautiful morning", "day")
end

def test_excerpt_old_api_is_depcrecated
assert_deprecated("Calling excerpt with radius and omission as arguments is deprecated. Please call with :radius => 5 instead.") do
excerpt("This is a beautiful morning", "morning", 5)
excerpt("This is a beautiful morning", "morning", 5)
end
assert_deprecated("Calling excerpt with radius and omission as arguments is deprecated. Please call with :radius => 5, :omission => 'mor' instead.") do
excerpt("This is a beautiful morning", "morning", 5, "mor")
excerpt("This is a beautiful morning", "morning", 5, "mor")
end
end

Expand Down Expand Up @@ -253,10 +253,10 @@ def test_excerpt_with_omission
if RUBY_VERSION < '1.9'
def test_excerpt_with_utf8
with_kcode('u') do
assert_equal("...\357\254\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', :line_width => 8))
assert_equal("...\357\254\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', :radius => 8))
end
with_kcode('none') do
assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', :line_width => 8))
assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', :radius => 8))
end
end
else
Expand All @@ -270,7 +270,7 @@ def test_excerpt_with_utf8
def test_word_wrap
assert_equal("my very very\nvery long\nstring", word_wrap("my very very very long string", :line_width => 15))
end

def test_word_wrap_old_api_is_depcrecated
assert_deprecated("Calling word_wrap with line_width as an argument is deprecated. Please call with :line_width => 15 instead.") do
word_wrap("my very very very long string", 15)
Expand Down

0 comments on commit c520504

Please sign in to comment.