summaryrefslogtreecommitdiffstats
path: root/test/functional/search_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-16 07:43:16 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-16 07:43:16 +0000
commit6cc6a918b4f36dbad445a5756f174b767e4ad61b (patch)
tree87704465c1a28284c466744eb6418cbd8adb1e22 /test/functional/search_controller_test.rb
parent11c85279ab2a8e660666e2c0c80025e2e2513940 (diff)
downloadredmine-6cc6a918b4f36dbad445a5756f174b767e4ad61b.tar.gz
redmine-6cc6a918b4f36dbad445a5756f174b767e4ad61b.zip
Pass parameters with :params in controller tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@15666 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/search_controller_test.rb')
-rw-r--r--test/functional/search_controller_test.rb77
1 files changed, 39 insertions, 38 deletions
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
index 9764d3adf..ae4943d9d 100644
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -35,7 +35,7 @@ class SearchControllerTest < Redmine::ControllerTest
assert_response :success
assert_template 'index'
- get :index, :q => "cook"
+ get :index, :params => {:q => "cook"}
assert_response :success
assert_template 'index'
assert assigns(:results).include?(Project.find(1))
@@ -43,30 +43,30 @@ class SearchControllerTest < Redmine::ControllerTest
def test_search_on_archived_project_should_return_404
Project.find(3).archive
- get :index, :id => 3
+ get :index, :params => {:id => 3}
assert_response 404
end
def test_search_on_invisible_project_by_user_should_be_denied
@request.session[:user_id] = 7
- get :index, :id => 2
+ get :index, :params => {:id => 2}
assert_response 403
end
def test_search_on_invisible_project_by_anonymous_user_should_redirect
- get :index, :id => 2
+ get :index, :params => {:id => 2}
assert_response 302
end
def test_search_on_private_project_by_member_should_succeed
@request.session[:user_id] = 2
- get :index, :id => 2
+ get :index, :params => {:id => 2}
assert_response :success
end
def test_search_all_projects
with_settings :default_language => 'en' do
- get :index, :q => 'recipe subproject commit', :all_words => ''
+ get :index, :params => {:q => 'recipe subproject commit', :all_words => ''}
end
assert_response :success
assert_template 'index'
@@ -83,7 +83,7 @@ class SearchControllerTest < Redmine::ControllerTest
end
def test_search_issues
- get :index, :q => 'issue', :issues => 1
+ get :index, :params => {:q => 'issue', :issues => 1}
assert_response :success
assert_template 'index'
@@ -97,7 +97,7 @@ class SearchControllerTest < Redmine::ControllerTest
def test_search_issues_should_search_notes
Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword')
- get :index, :q => 'searchkeyword', :issues => 1
+ get :index, :params => {:q => 'searchkeyword', :issues => 1}
assert_response :success
assert_include Issue.find(2), assigns(:results)
end
@@ -106,7 +106,7 @@ class SearchControllerTest < Redmine::ControllerTest
Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword')
Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword')
- get :index, :q => 'searchkeyword', :issues => 1
+ get :index, :params => {:q => 'searchkeyword', :issues => 1}
assert_response :success
assert_include Issue.find(2), assigns(:results)
assert_equal 1, assigns(:results).size
@@ -117,18 +117,18 @@ class SearchControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
Role.find(1).add_permission! :view_private_notes
- get :index, :q => 'searchkeyword', :issues => 1
+ get :index, :params => {:q => 'searchkeyword', :issues => 1}
assert_response :success
assert_include Issue.find(2), assigns(:results)
Role.find(1).remove_permission! :view_private_notes
- get :index, :q => 'searchkeyword', :issues => 1
+ get :index, :params => {:q => 'searchkeyword', :issues => 1}
assert_response :success
assert_not_include Issue.find(2), assigns(:results)
end
def test_search_all_projects_with_scope_param
- get :index, :q => 'issue', :scope => 'all'
+ get :index, :params => {:q => 'issue', :scope => 'all'}
assert_response :success
assert_template 'index'
assert assigns(:results).present?
@@ -136,7 +136,7 @@ class SearchControllerTest < Redmine::ControllerTest
def test_search_my_projects
@request.session[:user_id] = 2
- get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''
+ get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''}
assert_response :success
assert_template 'index'
assert assigns(:results).include?(Issue.find(1))
@@ -145,14 +145,14 @@ class SearchControllerTest < Redmine::ControllerTest
def test_search_my_projects_without_memberships
# anonymous user has no memberships
- get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''
+ get :index, :params => {: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 => ''
+ get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''}
assert_response :success
assert_template 'index'
assert assigns(:results).include?(Issue.find(1))
@@ -162,18 +162,18 @@ class SearchControllerTest < Redmine::ControllerTest
def test_search_without_searchable_custom_fields
CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
- get :index, :id => 1
+ get :index, :params => {:id => 1}
assert_response :success
assert_template 'index'
assert_not_nil assigns(:project)
- get :index, :id => 1, :q => "can"
+ get :index, :params => {:id => 1, :q => "can"}
assert_response :success
assert_template 'index'
end
def test_search_with_searchable_custom_fields
- get :index, :id => 1, :q => "stringforcustomfield"
+ get :index, :params => {:id => 1, :q => "stringforcustomfield"}
assert_response :success
results = assigns(:results)
assert_not_nil results
@@ -185,7 +185,7 @@ class SearchControllerTest < Redmine::ControllerTest
issue = Issue.generate! :subject => 'search_attachments'
attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
- get :index, :id => 1, :q => 'search_attachments', :attachments => '0'
+ get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '0'}
results = assigns(:results)
assert_equal 1, results.size
assert_equal issue, results.first
@@ -195,7 +195,7 @@ class SearchControllerTest < Redmine::ControllerTest
issue = Issue.generate! :subject => 'search_attachments'
attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
- get :index, :id => 1, :q => 'search_attachments', :attachments => 'only'
+ get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => 'only'}
results = assigns(:results)
assert_equal 1, results.size
assert_equal attachment.container, results.first
@@ -205,7 +205,7 @@ class SearchControllerTest < Redmine::ControllerTest
Issue.generate! :subject => 'search_attachments'
Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
- get :index, :id => 1, :q => 'search_attachments', :attachments => '1'
+ get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '1'}
results = assigns(:results)
assert_equal 2, results.size
end
@@ -214,14 +214,14 @@ class SearchControllerTest < Redmine::ControllerTest
Issue.generate! :subject => 'search_open'
Issue.generate! :subject => 'search_open', :status_id => 5
- get :index, :id => 1, :q => 'search_open', :open_issues => '1'
+ get :index, :params => {:id => 1, :q => 'search_open', :open_issues => '1'}
results = assigns(:results)
assert_equal 1, results.size
end
def test_search_all_words
# 'all words' is on by default
- get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1'
+ get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => '1'}
assert_equal true, assigns(:all_words)
results = assigns(:results)
assert_not_nil results
@@ -230,7 +230,7 @@ class SearchControllerTest < Redmine::ControllerTest
end
def test_search_one_of_the_words
- get :index, :id => 1, :q => 'recipe updating saving', :all_words => ''
+ get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => ''}
assert_equal false, assigns(:all_words)
results = assigns(:results)
assert_not_nil results
@@ -239,14 +239,14 @@ class SearchControllerTest < Redmine::ControllerTest
end
def test_search_titles_only_without_result
- get :index, :id => 1, :q => 'recipe updating saving', :titles_only => '1'
+ get :index, :params => {:id => 1, :q => 'recipe updating saving', :titles_only => '1'}
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'
+ get :index, :params => {:id => 1, :q => 'recipe', :titles_only => '1'}
assert_equal true, assigns(:titles_only)
results = assigns(:results)
assert_not_nil results
@@ -255,7 +255,8 @@ class SearchControllerTest < Redmine::ControllerTest
def test_search_content
Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'")
- get :index, :id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''
+
+ get :index, :params => {:id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''}
assert_equal false, assigns(:titles_only)
results = assigns(:results)
assert_not_nil results
@@ -265,54 +266,54 @@ class SearchControllerTest < Redmine::ControllerTest
def test_search_with_pagination
issue = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse
- get :index, :q => 'search_with_limited_results'
+ get :index, :params => {:q => 'search_with_limited_results'}
assert_response :success
assert_equal issue[0..9], assigns(:results)
- get :index, :q => 'search_with_limited_results', :page => 2
+ get :index, :params => {:q => 'search_with_limited_results', :page => 2}
assert_response :success
assert_equal issue[10..19], assigns(:results)
- get :index, :q => 'search_with_limited_results', :page => 3
+ get :index, :params => {:q => 'search_with_limited_results', :page => 3}
assert_response :success
assert_equal issue[20..24], assigns(:results)
- get :index, :q => 'search_with_limited_results', :page => 4
+ get :index, :params => {:q => 'search_with_limited_results', :page => 4}
assert_response :success
assert_equal [], assigns(:results)
end
def test_search_with_invalid_project_id
- get :index, :id => 195, :q => 'recipe'
+ get :index, :params => {:id => 195, :q => 'recipe'}
assert_response 404
assert_nil assigns(:results)
end
def test_quick_jump_to_issue
# issue of a public project
- get :index, :q => "3"
+ get :index, :params => {:q => "3"}
assert_redirected_to '/issues/3'
# issue of a private project
- get :index, :q => "4"
+ get :index, :params => {:q => "4"}
assert_response :success
assert_template 'index'
end
def test_large_integer
- get :index, :q => '4615713488'
+ get :index, :params => {:q => '4615713488'}
assert_response :success
assert_template 'index'
end
def test_tokens_with_quotes
- get :index, :id => 1, :q => '"good bye" hello "bye bye"'
+ get :index, :params => {:id => 1, :q => '"good bye" hello "bye bye"'}
assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens)
end
def test_results_should_be_escaped_once
assert Issue.find(1).update_attributes(:subject => '<subject> escaped_once', :description => '<description> escaped_once')
- get :index, :q => 'escaped_once'
+ get :index, :params => {:q => 'escaped_once'}
assert_response :success
assert_select '#search-results' do
assert_select 'dt.issue a', :text => /<subject>/
@@ -322,7 +323,7 @@ class SearchControllerTest < Redmine::ControllerTest
def test_keywords_should_be_highlighted
assert Issue.find(1).update_attributes(:subject => 'subject highlighted', :description => 'description highlighted')
- get :index, :q => 'highlighted'
+ get :index, :params => {:q => 'highlighted'}
assert_response :success
assert_select '#search-results' do
assert_select 'dt.issue a span.highlight', :text => 'highlighted'