Commit ca94709f74956635a04a4d9656b5e73706d47476

Authored by MoisesMachado
1 parent a65775c7

ActionItem128: search now filter stopwords preserving only those protected with quotes


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1199 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/search_helper.rb
@@ -12,6 +12,6 @@ module SearchHelper @@ -12,6 +12,6 @@ module SearchHelper
12 end 12 end
13 13
14 def remove_stop_words(query) 14 def remove_stop_words(query)
15 - (query.downcase.split(/[ '".]/) - STOP_WORDS[Locale.current.to_s]).join(' ') 15 + (query.downcase.scan(/"[^"]*"?|'[^']*'?|[^'"\s]+/) - STOP_WORDS[Locale.current.to_s]).join(' ')
16 end 16 end
17 end 17 end
test/functional/search_controller_test.rb
@@ -22,6 +22,7 @@ class SearchControllerTest < Test::Unit::TestCase @@ -22,6 +22,7 @@ class SearchControllerTest < Test::Unit::TestCase
22 end 22 end
23 23
24 should 'filter stop words' do 24 should 'filter stop words' do
  25 + Locale.current = Locale::Object.new('pt_BR')
25 get 'index', :query => 'a carne da vaca' 26 get 'index', :query => 'a carne da vaca'
26 assert_response :success 27 assert_response :success
27 assert_template 'index' 28 assert_template 'index'