diff --git a/test/fixtures/issues.yml b/test/fixtures/issues.yml
index fc5b48dee0cf64433207eba5cbe9fbce31e12fd2..b3c662039371424939d88e1866780ba5eb346bf6 100644
--- a/test/fixtures/issues.yml
+++ b/test/fixtures/issues.yml
@@ -22,7 +22,7 @@ issues_002:
   id: 2
   fixed_version_id: 
   category_id: 
-  description: Ingredients should be classified by categories
+  description: Ingredients of the recipe should be classified by categories
   tracker_id: 2
   assigned_to_id: 3
   author_id: 2
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
index 330cd0de02f02d63ffbd3bc630056a882aa28378..63f1097d6d3a4e149c98cbb4c836d0e332f6a93c 100644
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -5,7 +5,7 @@ require 'search_controller'
 class SearchController; def rescue_action(e) raise e end; end
 
 class SearchControllerTest < Test::Unit::TestCase
-  fixtures :projects, :issues, :custom_fields, :custom_values
+  fixtures :projects, :enabled_modules, :issues, :custom_fields, :custom_values
   
   def setup
     @controller = SearchController.new
@@ -47,6 +47,37 @@ class SearchControllerTest < Test::Unit::TestCase
     assert results.include?(Issue.find(3))
   end
   
+  def test_search_all_words
+    # 'all words' is on by default
+    get :index, :id => 1, :q => 'recipe updating saving'
+    results = assigns(:results)
+    assert_not_nil results
+    assert_equal 1, results.size
+    assert results.include?(Issue.find(3))
+  end
+  
+  def test_search_one_of_the_words
+    get :index, :id => 1, :q => 'recipe updating saving', :submit => 'Search'
+    results = assigns(:results)
+    assert_not_nil results
+    assert_equal 3, results.size
+    assert results.include?(Issue.find(3))
+  end
+
+  def test_search_titles_only_without_result
+    get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1', :titles_only => '1', :submit => 'Search'
+    results = assigns(:results)
+    assert_not_nil results
+    assert_equal 0, results.size
+  end
+
+  def test_search_titles_only
+    get :index, :id => 1, :q => 'recipe', :titles_only => '1', :submit => 'Search'
+    results = assigns(:results)
+    assert_not_nil results
+    assert_equal 2, results.size
+  end
+  
   def test_quick_jump_to_issue
     # issue of a public project
     get :index, :q => "3"
diff --git a/vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb b/vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb
index 1dd88978cd36a9579ea17fcd257723259a923dbf..dff76b91314902e4116b8769734d1ef84785fc7a 100644
--- a/vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb
+++ b/vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb
@@ -85,7 +85,7 @@ module Redmine
               end
             end
             
-            sql = ([token_clauses.join(' OR ')] * tokens.size).join(options[:all_words] ? ' AND ' : ' OR ')
+            sql = (['(' + token_clauses.join(' OR ') + ')'] * tokens.size).join(options[:all_words] ? ' AND ' : ' OR ')
             
             if options[:offset]
               sql = "(#{sql}) AND (#{searchable_options[:date_column]} " + (options[:before] ? '<' : '>') + "'#{connection.quoted_date(options[:offset])}')"