diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-30 08:52:39 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-30 08:52:39 +0000 |
commit | ebe10fa6452de7ea6c5759bfd9c7b439091b54cd (patch) | |
tree | 30eb8f2f6fb758c41530597814c2e9d048fc75c8 /test/functional/search_controller_test.rb | |
parent | 833c5035a697858cfc390b08e5db204ba30831d9 (diff) | |
download | redmine-ebe10fa6452de7ea6c5759bfd9c7b439091b54cd.tar.gz redmine-ebe10fa6452de7ea6c5759bfd9c7b439091b54cd.zip |
Added a quick search form in page header. Search functionality moved to a dedicated controller.
When used:
* outside of a project: searches projects
* inside a project: searches issues, changesets, news, documents and wiki pages of the current project
If an issue number is given, user is redirected to the corresponding issue.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@489 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/search_controller_test.rb')
-rw-r--r-- | test/functional/search_controller_test.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb new file mode 100644 index 000000000..8fa2e0890 --- /dev/null +++ b/test/functional/search_controller_test.rb @@ -0,0 +1,48 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'search_controller' + +# Re-raise errors caught by the controller. +class SearchController; def rescue_action(e) raise e end; end + +class SearchControllerTest < Test::Unit::TestCase + fixtures :projects, :issues + + def setup + @controller = SearchController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_search_for_projects + get :index + assert_response :success + assert_template 'index' + + get :index, :q => "cook" + assert_response :success + assert_template 'index' + assert assigns(:results).include?(Project.find(1)) + end + + def test_search_in_project + get :index, :id => 1 + assert_response :success + assert_template 'index' + assert_not_nil assigns(:project) + + get :index, :id => 1, :q => "can", :scope => ["issues", "news", "documents"] + assert_response :success + assert_template 'index' + end + + def test_quick_jump_to_issue + # issue of a public project + get :index, :q => "3" + assert_redirected_to 'issues/show/3' + + # issue of a private project + get :index, :q => "4" + assert_response :success + assert_template 'index' + end +end |