require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/test_case' require 'search_controller' # Re-raise errors caught by the controller. class SearchController; def rescue_action(e) raise e end; end class SearchControllerTest < Functional::TestCase fixtures :tickets, :ticket_changes, :changesets, :changes, :statuses, :priorities, :repositories def setup RetroCM.reload @controller = SearchController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new login(User.public_user) Project.current = Project.find(1) end def teardown Project.current = nil end def test_index assert(User.current.access_permitted?(:controller => 'search', :action => 'index')) get :index assert_response :success assert_template 'search/index' assert_valid_markup get :index, :q => 'deleted', :all => '1' assert_response :success assert_template 'search/index' assert_valid_markup assert_select 'body .search h3', ENABLE_SUBVERSION ? 2 : 0 get :index, :q => 'serious', :all => '1' assert_response :success assert_template 'search/index' assert_valid_markup assert_select 'body .search h3', 3 # Test with multiple keywords get :index, :q => 'serious serious serious', :all => '1' assert_response :success assert_template 'search/index' assert_valid_markup assert_select 'body .search h3', 3 get :index, :q => 'serious', :ticket_changes => '1' assert_response :success assert_template 'search/index' assert_valid_markup assert_select 'body .search h3', 1 get :index, :q => 'serious', :tickets => '1' assert_response :success assert_template 'search/index' assert_valid_markup assert_select 'body .search h3', 2 get :index, :q => 'some_not_included_string', :all => '1' assert_response :success assert_template 'search/index' assert_valid_markup assert_select 'body .search h3', 0 end def test_pattern_based_search get :index, :q => 'Very serious issue description', :tickets => '1' assert_response :success assert_template 'search/index' assert_valid_markup assert_select 'body .search h3', 2 get :index, :q => '"Very serious issue description"', :tickets => '1' assert_response :success assert_select 'body .search h3', 1 get :index, :q => '+Very +serious +issue +description -2nd', :tickets => '1' assert_response :success assert_select 'body .search h3', 1 end end