##// END OF EJS Templates
remove trailing white-spaces from functional search controller test....
Toshi MARUYAMA -
r5683:5e1576b8b4e5
parent child
Show More
@@ -9,14 +9,14 class SearchControllerTest < ActionController::TestCase
9 :issues, :trackers, :issue_statuses,
9 :issues, :trackers, :issue_statuses,
10 :custom_fields, :custom_values,
10 :custom_fields, :custom_values,
11 :repositories, :changesets
11 :repositories, :changesets
12
12
13 def setup
13 def setup
14 @controller = SearchController.new
14 @controller = SearchController.new
15 @request = ActionController::TestRequest.new
15 @request = ActionController::TestRequest.new
16 @response = ActionController::TestResponse.new
16 @response = ActionController::TestResponse.new
17 User.current = nil
17 User.current = nil
18 end
18 end
19
19
20 def test_search_for_projects
20 def test_search_for_projects
21 get :index
21 get :index
22 assert_response :success
22 assert_response :success
@@ -27,35 +27,35 class SearchControllerTest < ActionController::TestCase
27 assert_template 'index'
27 assert_template 'index'
28 assert assigns(:results).include?(Project.find(1))
28 assert assigns(:results).include?(Project.find(1))
29 end
29 end
30
30
31 def test_search_all_projects
31 def test_search_all_projects
32 get :index, :q => 'recipe subproject commit', :submit => 'Search'
32 get :index, :q => 'recipe subproject commit', :submit => 'Search'
33 assert_response :success
33 assert_response :success
34 assert_template 'index'
34 assert_template 'index'
35
35
36 assert assigns(:results).include?(Issue.find(2))
36 assert assigns(:results).include?(Issue.find(2))
37 assert assigns(:results).include?(Issue.find(5))
37 assert assigns(:results).include?(Issue.find(5))
38 assert assigns(:results).include?(Changeset.find(101))
38 assert assigns(:results).include?(Changeset.find(101))
39 assert_tag :dt, :attributes => { :class => /issue/ },
39 assert_tag :dt, :attributes => { :class => /issue/ },
40 :child => { :tag => 'a', :content => /Add ingredients categories/ },
40 :child => { :tag => 'a', :content => /Add ingredients categories/ },
41 :sibling => { :tag => 'dd', :content => /should be classified by categories/ }
41 :sibling => { :tag => 'dd', :content => /should be classified by categories/ }
42
42
43 assert assigns(:results_by_type).is_a?(Hash)
43 assert assigns(:results_by_type).is_a?(Hash)
44 assert_equal 5, assigns(:results_by_type)['changesets']
44 assert_equal 5, assigns(:results_by_type)['changesets']
45 assert_tag :a, :content => 'Changesets (5)'
45 assert_tag :a, :content => 'Changesets (5)'
46 end
46 end
47
47
48 def test_search_issues
48 def test_search_issues
49 get :index, :q => 'issue', :issues => 1
49 get :index, :q => 'issue', :issues => 1
50 assert_response :success
50 assert_response :success
51 assert_template 'index'
51 assert_template 'index'
52
52
53 assert assigns(:results).include?(Issue.find(8))
53 assert assigns(:results).include?(Issue.find(8))
54 assert assigns(:results).include?(Issue.find(5))
54 assert assigns(:results).include?(Issue.find(5))
55 assert_tag :dt, :attributes => { :class => /issue closed/ },
55 assert_tag :dt, :attributes => { :class => /issue closed/ },
56 :child => { :tag => 'a', :content => /Closed/ }
56 :child => { :tag => 'a', :content => /Closed/ }
57 end
57 end
58
58
59 def test_search_project_and_subprojects
59 def test_search_project_and_subprojects
60 get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :submit => 'Search'
60 get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :submit => 'Search'
61 assert_response :success
61 assert_response :success
@@ -66,17 +66,17 class SearchControllerTest < ActionController::TestCase
66
66
67 def test_search_without_searchable_custom_fields
67 def test_search_without_searchable_custom_fields
68 CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
68 CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
69
69
70 get :index, :id => 1
70 get :index, :id => 1
71 assert_response :success
71 assert_response :success
72 assert_template 'index'
72 assert_template 'index'
73 assert_not_nil assigns(:project)
73 assert_not_nil assigns(:project)
74
74
75 get :index, :id => 1, :q => "can"
75 get :index, :id => 1, :q => "can"
76 assert_response :success
76 assert_response :success
77 assert_template 'index'
77 assert_template 'index'
78 end
78 end
79
79
80 def test_search_with_searchable_custom_fields
80 def test_search_with_searchable_custom_fields
81 get :index, :id => 1, :q => "stringforcustomfield"
81 get :index, :id => 1, :q => "stringforcustomfield"
82 assert_response :success
82 assert_response :success
@@ -85,7 +85,7 class SearchControllerTest < ActionController::TestCase
85 assert_equal 1, results.size
85 assert_equal 1, results.size
86 assert results.include?(Issue.find(7))
86 assert results.include?(Issue.find(7))
87 end
87 end
88
88
89 def test_search_all_words
89 def test_search_all_words
90 # 'all words' is on by default
90 # 'all words' is on by default
91 get :index, :id => 1, :q => 'recipe updating saving'
91 get :index, :id => 1, :q => 'recipe updating saving'
@@ -94,7 +94,7 class SearchControllerTest < ActionController::TestCase
94 assert_equal 1, results.size
94 assert_equal 1, results.size
95 assert results.include?(Issue.find(3))
95 assert results.include?(Issue.find(3))
96 end
96 end
97
97
98 def test_search_one_of_the_words
98 def test_search_one_of_the_words
99 get :index, :id => 1, :q => 'recipe updating saving', :submit => 'Search'
99 get :index, :id => 1, :q => 'recipe updating saving', :submit => 'Search'
100 results = assigns(:results)
100 results = assigns(:results)
@@ -116,7 +116,7 class SearchControllerTest < ActionController::TestCase
116 assert_not_nil results
116 assert_not_nil results
117 assert_equal 2, results.size
117 assert_equal 2, results.size
118 end
118 end
119
119
120 def test_search_with_invalid_project_id
120 def test_search_with_invalid_project_id
121 get :index, :id => 195, :q => 'recipe'
121 get :index, :id => 195, :q => 'recipe'
122 assert_response 404
122 assert_response 404
@@ -127,7 +127,7 class SearchControllerTest < ActionController::TestCase
127 # issue of a public project
127 # issue of a public project
128 get :index, :q => "3"
128 get :index, :q => "3"
129 assert_redirected_to '/issues/3'
129 assert_redirected_to '/issues/3'
130
130
131 # issue of a private project
131 # issue of a private project
132 get :index, :q => "4"
132 get :index, :q => "4"
133 assert_response :success
133 assert_response :success
@@ -139,7 +139,7 class SearchControllerTest < ActionController::TestCase
139 assert_response :success
139 assert_response :success
140 assert_template 'index'
140 assert_template 'index'
141 end
141 end
142
142
143 def test_tokens_with_quotes
143 def test_tokens_with_quotes
144 get :index, :id => 1, :q => '"good bye" hello "bye bye"'
144 get :index, :id => 1, :q => '"good bye" hello "bye bye"'
145 assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens)
145 assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens)
General Comments 0
You need to be logged in to leave comments. Login now