##// END OF EJS Templates
remove trailing white-spaces from test/functional/search_controller_test.rb....
Toshi MARUYAMA -
r6804:1fe58f503c56
parent child
Show More
@@ -1,162 +1,162
1 1 require File.expand_path('../../test_helper', __FILE__)
2 2 require 'search_controller'
3 3
4 4 # Re-raise errors caught by the controller.
5 5 class SearchController; def rescue_action(e) raise e end; end
6 6
7 7 class SearchControllerTest < ActionController::TestCase
8 8 fixtures :projects, :enabled_modules, :roles, :users, :members, :member_roles,
9 9 :issues, :trackers, :issue_statuses,
10 10 :custom_fields, :custom_values,
11 11 :repositories, :changesets
12 12
13 13 def setup
14 14 @controller = SearchController.new
15 15 @request = ActionController::TestRequest.new
16 16 @response = ActionController::TestResponse.new
17 17 User.current = nil
18 18 end
19 19
20 20 def test_search_for_projects
21 21 get :index
22 22 assert_response :success
23 23 assert_template 'index'
24 24
25 25 get :index, :q => "cook"
26 26 assert_response :success
27 27 assert_template 'index'
28 28 assert assigns(:results).include?(Project.find(1))
29 29 end
30 30
31 31 def test_search_all_projects
32 32 get :index, :q => 'recipe subproject commit', :all_words => ''
33 33 assert_response :success
34 34 assert_template 'index'
35 35
36 36 assert assigns(:results).include?(Issue.find(2))
37 37 assert assigns(:results).include?(Issue.find(5))
38 38 assert assigns(:results).include?(Changeset.find(101))
39 39 assert_tag :dt, :attributes => { :class => /issue/ },
40 40 :child => { :tag => 'a', :content => /Add ingredients categories/ },
41 41 :sibling => { :tag => 'dd', :content => /should be classified by categories/ }
42 42
43 43 assert assigns(:results_by_type).is_a?(Hash)
44 44 assert_equal 5, assigns(:results_by_type)['changesets']
45 45 assert_tag :a, :content => 'Changesets (5)'
46 46 end
47 47
48 48 def test_search_issues
49 49 get :index, :q => 'issue', :issues => 1
50 50 assert_response :success
51 51 assert_template 'index'
52 52
53 53 assert_equal true, assigns(:all_words)
54 54 assert_equal false, assigns(:titles_only)
55 55 assert assigns(:results).include?(Issue.find(8))
56 56 assert assigns(:results).include?(Issue.find(5))
57 57 assert_tag :dt, :attributes => { :class => /issue closed/ },
58 58 :child => { :tag => 'a', :content => /Closed/ }
59 59 end
60 60
61 61 def test_search_project_and_subprojects
62 62 get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''
63 63 assert_response :success
64 64 assert_template 'index'
65 65 assert assigns(:results).include?(Issue.find(1))
66 66 assert assigns(:results).include?(Issue.find(5))
67 67 end
68 68
69 69 def test_search_without_searchable_custom_fields
70 70 CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
71 71
72 72 get :index, :id => 1
73 73 assert_response :success
74 74 assert_template 'index'
75 75 assert_not_nil assigns(:project)
76 76
77 77 get :index, :id => 1, :q => "can"
78 78 assert_response :success
79 79 assert_template 'index'
80 80 end
81 81
82 82 def test_search_with_searchable_custom_fields
83 83 get :index, :id => 1, :q => "stringforcustomfield"
84 84 assert_response :success
85 85 results = assigns(:results)
86 86 assert_not_nil results
87 87 assert_equal 1, results.size
88 88 assert results.include?(Issue.find(7))
89 89 end
90 90
91 91 def test_search_all_words
92 92 # 'all words' is on by default
93 93 get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1'
94 94 assert_equal true, assigns(:all_words)
95 95 results = assigns(:results)
96 96 assert_not_nil results
97 97 assert_equal 1, results.size
98 98 assert results.include?(Issue.find(3))
99 99 end
100 100
101 101 def test_search_one_of_the_words
102 102 get :index, :id => 1, :q => 'recipe updating saving', :all_words => ''
103 103 assert_equal false, assigns(:all_words)
104 104 results = assigns(:results)
105 105 assert_not_nil results
106 106 assert_equal 3, results.size
107 107 assert results.include?(Issue.find(3))
108 108 end
109 109
110 110 def test_search_titles_only_without_result
111 111 get :index, :id => 1, :q => 'recipe updating saving', :titles_only => '1'
112 112 results = assigns(:results)
113 113 assert_not_nil results
114 114 assert_equal 0, results.size
115 115 end
116 116
117 117 def test_search_titles_only
118 118 get :index, :id => 1, :q => 'recipe', :titles_only => '1'
119 119 assert_equal true, assigns(:titles_only)
120 120 results = assigns(:results)
121 121 assert_not_nil results
122 122 assert_equal 2, results.size
123 123 end
124 124
125 125 def test_search_content
126 126 Issue.update_all("description = 'This is a searchkeywordinthecontent'", "id=1")
127
127
128 128 get :index, :id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''
129 129 assert_equal false, assigns(:titles_only)
130 130 results = assigns(:results)
131 131 assert_not_nil results
132 132 assert_equal 1, results.size
133 133 end
134 134
135 135 def test_search_with_invalid_project_id
136 136 get :index, :id => 195, :q => 'recipe'
137 137 assert_response 404
138 138 assert_nil assigns(:results)
139 139 end
140 140
141 141 def test_quick_jump_to_issue
142 142 # issue of a public project
143 143 get :index, :q => "3"
144 144 assert_redirected_to '/issues/3'
145 145
146 146 # issue of a private project
147 147 get :index, :q => "4"
148 148 assert_response :success
149 149 assert_template 'index'
150 150 end
151 151
152 152 def test_large_integer
153 153 get :index, :q => '4615713488'
154 154 assert_response :success
155 155 assert_template 'index'
156 156 end
157 157
158 158 def test_tokens_with_quotes
159 159 get :index, :id => 1, :q => '"good bye" hello "bye bye"'
160 160 assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens)
161 161 end
162 162 end
General Comments 0
You need to be logged in to leave comments. Login now