summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/projects_controller_test.rb10
-rw-r--r--test/functional/search_controller_test.rb48
2 files changed, 48 insertions, 10 deletions
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index 644da830d..6e76be2d1 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -125,14 +125,4 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_template 'activity'
assert_not_nil assigns(:events_by_day)
end
-
- def test_search
- get :search, :id => 1
- assert_response :success
- assert_template 'search'
-
- get :search, :id => 1, :token => "can", :scope => ["issues", "news", "documents"]
- assert_response :success
- assert_template 'search'
- end
end
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