diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/javascript_helper_test.rb | 4 |
3 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index c46ed35f42..f46b6fd700 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed JavascriptHelper#auto_complete_for to only include unique items #2153 [Thomas Fuchs] + * Fixed all AssetHelper methods to work with relative paths, such that javascript_include_tag('stdlib/standard') will look in /javascripts/stdlib/standard instead of '/stdlib/standard/' #1963 * Avoid extending view instance with helper modules each request. Closes #1979 diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index e6985c5eb7..90b7100dff 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -396,7 +396,7 @@ module ActionView def auto_complete_result(entries, field, phrase = nil) return unless entries items = entries.map { |entry| content_tag("li", phrase ? highlight(entry[field], phrase) : h(entry[field])) } - content_tag("ul", items) + content_tag("ul", items.uniq) end # Wrapper for text_field with added AJAX autocompletion functionality. diff --git a/actionpack/test/template/javascript_helper_test.rb b/actionpack/test/template/javascript_helper_test.rb index 15e98654f0..46242355b3 100644 --- a/actionpack/test/template/javascript_helper_test.rb +++ b/actionpack/test/template/javascript_helper_test.rb @@ -127,6 +127,10 @@ class JavaScriptHelperTest < Test::Unit::TestCase auto_complete_result(result, :title) assert_equal %(<ul><li>t<strong class=\"highlight\">est</strong>1</li><li>t<strong class=\"highlight\">est</strong>2</li></ul>), auto_complete_result(result, :title, "est") + + resultuniq = [ { :title => 'test1' }, { :title => 'test1' } ] + assert_equal %(<ul><li>t<strong class=\"highlight\">est</strong>1</li></ul>), + auto_complete_result(resultuniq, :title, "est") end def test_text_field_with_auto_complete |