summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-17 18:23:53 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-17 18:23:53 +0000
commitbb0cd34f4e2e3aee82b763aa6f23518072e99f08 (patch)
treede3c3dc8ee6228ae4646389f720953d2313e531a /test
parent199eaff14ea3217efd0ee2592abb88798e465338 (diff)
downloadredmine-bb0cd34f4e2e3aee82b763aa6f23518072e99f08.tar.gz
redmine-bb0cd34f4e2e3aee82b763aa6f23518072e99f08.zip
Additional tests for SearchController and handle my_projects scope without memberships.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8266 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/search_controller_test.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
index 9e48e7f2e..fc40ce2f0 100644
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -58,6 +58,30 @@ class SearchControllerTest < ActionController::TestCase
:child => { :tag => 'a', :content => /Closed/ }
end
+ def test_search_all_projects_with_scope_param
+ get :index, :q => 'issue', :scope => 'all'
+ assert_response :success
+ assert_template 'index'
+ assert assigns(:results).present?
+ end
+
+ def test_search_my_projects
+ @request.session[:user_id] = 2
+ get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''
+ assert_response :success
+ assert_template 'index'
+ assert assigns(:results).include?(Issue.find(1))
+ assert !assigns(:results).include?(Issue.find(5))
+ end
+
+ def test_search_my_projects_without_memberships
+ # anonymous user has no memberships
+ get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''
+ assert_response :success
+ assert_template 'index'
+ assert assigns(:results).empty?
+ end
+
def test_search_project_and_subprojects
get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''
assert_response :success
@@ -132,6 +156,22 @@ class SearchControllerTest < ActionController::TestCase
assert_equal 1, results.size
end
+ def test_search_with_offset
+ get :index, :q => 'coo', :offset => '20080806073000'
+ assert_response :success
+ results = assigns(:results)
+ assert results.any?
+ assert results.map(&:event_datetime).max < '20080806T073000'.to_time
+ end
+
+ def test_search_previous_with_offset
+ get :index, :q => 'coo', :offset => '20080806073000', :previous => '1'
+ assert_response :success
+ results = assigns(:results)
+ assert results.any?
+ assert results.map(&:event_datetime).min >= '20080806T073000'.to_time
+ end
+
def test_search_with_invalid_project_id
get :index, :id => 195, :q => 'recipe'
assert_response 404