##// END OF EJS Templates
Removes calls to #assert_template and #assigns in functional tests....
Jean-Philippe Lang -
r15342:29ddc82a11f3
parent child
Show More
@@ -9,10 +9,10 wiki_content_versions_001:
9 wiki_content_id: 1
9 wiki_content_id: 1
10 compression: ""
10 compression: ""
11 data: |-
11 data: |-
12 h1. CookBook documentation
12 h1. CookBook documentation v1
13
13
14
14
15
15 Line from v1
16 Some [[documentation]] here...
16 Some [[documentation]] here...
17 wiki_content_versions_002:
17 wiki_content_versions_002:
18 updated_on: 2007-03-07 00:08:34 +01:00
18 updated_on: 2007-03-07 00:08:34 +01:00
@@ -24,10 +24,10 wiki_content_versions_002:
24 wiki_content_id: 1
24 wiki_content_id: 1
25 compression: ""
25 compression: ""
26 data: |-
26 data: |-
27 h1. CookBook documentation
27 h1. CookBook documentation v2
28
28
29
29
30
30 Line from v1
31 Some updated [[documentation]] here...
31 Some updated [[documentation]] here...
32 wiki_content_versions_003:
32 wiki_content_versions_003:
33 updated_on: 2007-03-07 00:10:51 +01:00
33 updated_on: 2007-03-07 00:10:51 +01:00
@@ -39,7 +39,8 wiki_content_versions_003:
39 wiki_content_id: 1
39 wiki_content_id: 1
40 compression: ""
40 compression: ""
41 data: |-
41 data: |-
42 h1. CookBook documentation
42 h1. CookBook documentation v3
43
43 Some updated [[documentation]] here...
44 Some updated [[documentation]] here...
44 wiki_content_versions_004:
45 wiki_content_versions_004:
45 data: |-
46 data: |-
@@ -161,14 +161,14 class BoardsControllerTest < Redmine::ControllerTest
161 post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'}
161 post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'}
162 end
162 end
163 assert_response :success
163 assert_response :success
164 assert_template 'new'
164 assert_select_error /Name cannot be blank/
165 end
165 end
166
166
167 def test_edit
167 def test_edit
168 @request.session[:user_id] = 2
168 @request.session[:user_id] = 2
169 get :edit, :project_id => 1, :id => 2
169 get :edit, :project_id => 1, :id => 2
170 assert_response :success
170 assert_response :success
171 assert_template 'edit'
171 assert_select 'input[name=?][value=?]', 'board[name]', 'Discussion'
172 end
172 end
173
173
174 def test_edit_with_parent
174 def test_edit_with_parent
@@ -176,7 +176,6 class BoardsControllerTest < Redmine::ControllerTest
176 @request.session[:user_id] = 2
176 @request.session[:user_id] = 2
177 get :edit, :project_id => 1, :id => board.id
177 get :edit, :project_id => 1, :id => board.id
178 assert_response :success
178 assert_response :success
179 assert_template 'edit'
180
179
181 assert_select 'select[name=?]', 'board[parent_id]' do
180 assert_select 'select[name=?]', 'board[parent_id]' do
182 assert_select 'option[value="2"][selected=selected]'
181 assert_select 'option[value="2"][selected=selected]'
@@ -204,7 +203,7 class BoardsControllerTest < Redmine::ControllerTest
204 @request.session[:user_id] = 2
203 @request.session[:user_id] = 2
205 put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'}
204 put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'}
206 assert_response :success
205 assert_response :success
207 assert_template 'edit'
206 assert_select_error /Name cannot be blank/
208 end
207 end
209
208
210 def test_destroy
209 def test_destroy
@@ -28,18 +28,17 class RolesControllerTest < Redmine::ControllerTest
28 def test_index
28 def test_index
29 get :index
29 get :index
30 assert_response :success
30 assert_response :success
31 assert_template 'index'
32
31
33 assert_not_nil assigns(:roles)
32 assert_select 'table.roles tbody' do
34 assert_equal Role.order('builtin, position').to_a, assigns(:roles)
33 assert_select 'tr', Role.count
35
34 assert_select 'a[href="/roles/1/edit"]', :text => 'Manager'
36 assert_select 'a[href="/roles/1/edit"]', :text => 'Manager'
35 end
37 end
36 end
38
37
39 def test_new
38 def test_new
40 get :new
39 get :new
41 assert_response :success
40 assert_response :success
42 assert_template 'new'
41 assert_select 'input[name=?]', 'role[name]'
43 end
42 end
44
43
45 def test_new_with_copy
44 def test_new_with_copy
@@ -47,10 +46,7 class RolesControllerTest < Redmine::ControllerTest
47
46
48 get :new, :params => {:copy => copy_from.id.to_s}
47 get :new, :params => {:copy => copy_from.id.to_s}
49 assert_response :success
48 assert_response :success
50 assert_template 'new'
49 assert_select 'input[name=?]', 'role[name]'
51
52 role = assigns(:role)
53 assert_equal copy_from.permissions, role.permissions
54
50
55 assert_select 'form' do
51 assert_select 'form' do
56 # blank name
52 # blank name
@@ -76,8 +72,7 class RolesControllerTest < Redmine::ControllerTest
76 }
72 }
77 }
73 }
78 assert_response :success
74 assert_response :success
79 assert_template 'new'
75 assert_select_error /Name cannot be blank/
80 assert_select 'div#errorExplanation'
81 end
76 end
82
77
83 def test_create_without_workflow_copy
78 def test_create_without_workflow_copy
@@ -113,15 +108,16 class RolesControllerTest < Redmine::ControllerTest
113 def test_edit
108 def test_edit
114 get :edit, :params => {:id => 1}
109 get :edit, :params => {:id => 1}
115 assert_response :success
110 assert_response :success
116 assert_template 'edit'
111
117 assert_equal Role.find(1), assigns(:role)
112 assert_select 'input[name=?][value=?]', 'role[name]', 'Manager'
118 assert_select 'select[name=?]', 'role[issues_visibility]'
113 assert_select 'select[name=?]', 'role[issues_visibility]'
119 end
114 end
120
115
121 def test_edit_anonymous
116 def test_edit_anonymous
122 get :edit, :params => {:id => Role.anonymous.id}
117 get :edit, :params => {:id => Role.anonymous.id}
123 assert_response :success
118 assert_response :success
124 assert_template 'edit'
119
120 assert_select 'input[name=?]', 'role[name]', 0
125 assert_select 'select[name=?]', 'role[issues_visibility]', 0
121 assert_select 'select[name=?]', 'role[issues_visibility]', 0
126 end
122 end
127
123
@@ -165,7 +161,7 class RolesControllerTest < Redmine::ControllerTest
165 def test_update_with_failure
161 def test_update_with_failure
166 put :update, :params => {:id => 1, :role => {:name => ''}}
162 put :update, :params => {:id => 1, :role => {:name => ''}}
167 assert_response :success
163 assert_response :success
168 assert_template 'edit'
164 assert_select_error /Name cannot be blank/
169 end
165 end
170
166
171 def test_destroy
167 def test_destroy
@@ -186,10 +182,6 class RolesControllerTest < Redmine::ControllerTest
186 def test_get_permissions
182 def test_get_permissions
187 get :permissions
183 get :permissions
188 assert_response :success
184 assert_response :success
189 assert_template 'permissions'
190
191 assert_not_nil assigns(:roles)
192 assert_equal Role.order('builtin, position').to_a, assigns(:roles)
193
185
194 assert_select 'input[name=?][type=checkbox][value=add_issues][checked=checked]', 'permissions[3][]'
186 assert_select 'input[name=?][type=checkbox][value=add_issues][checked=checked]', 'permissions[3][]'
195 assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]'
187 assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]'
@@ -30,15 +30,16 class SearchControllerTest < Redmine::ControllerTest
30 User.current = nil
30 User.current = nil
31 end
31 end
32
32
33 def test_search_for_projects
33 def test_search_without_q_should_display_search_form
34 get :index
34 get :index
35 assert_response :success
35 assert_response :success
36 assert_template 'index'
36 assert_select '#content input[name=q]'
37 end
37
38
39 def test_search_for_projects
38 get :index, :params => {:q => "cook"}
40 get :index, :params => {:q => "cook"}
39 assert_response :success
41 assert_response :success
40 assert_template 'index'
42 assert_select '#search-results dt.project a', :text => /eCookbook/
41 assert assigns(:results).include?(Project.find(1))
42 end
43 end
43
44
44 def test_search_on_archived_project_should_return_404
45 def test_search_on_archived_project_should_return_404
@@ -69,29 +70,32 class SearchControllerTest < Redmine::ControllerTest
69 get :index, :params => {:q => 'recipe subproject commit', :all_words => ''}
70 get :index, :params => {:q => 'recipe subproject commit', :all_words => ''}
70 end
71 end
71 assert_response :success
72 assert_response :success
72 assert_template 'index'
73
73
74 assert assigns(:results).include?(Issue.find(2))
74 assert_select '#search-results' do
75 assert assigns(:results).include?(Issue.find(5))
75 assert_select 'dt.issue a', :text => /Feature request #2/
76 assert assigns(:results).include?(Changeset.find(101))
76 assert_select 'dt.issue a', :text => /Bug #5/
77 assert_select 'dt.issue a', :text => /Add ingredients categories/
77 assert_select 'dt.changeset a', :text => /Revision 1/
78 assert_select 'dd', :text => /should be classified by categories/
78
79 assert_select 'dt.issue a', :text => /Add ingredients categories/
80 assert_select 'dd', :text => /should be classified by categories/
81 end
79
82
80 assert assigns(:result_count_by_type).is_a?(Hash)
83 assert_select '#search-results-counts' do
81 assert_equal 5, assigns(:result_count_by_type)['changesets']
84 assert_select 'a', :text => 'Changesets (5)'
82 assert_select 'a', :text => 'Changesets (5)'
85 end
83 end
86 end
84
87
85 def test_search_issues
88 def test_search_issues
86 get :index, :params => {:q => 'issue', :issues => 1}
89 get :index, :params => {:q => 'issue', :issues => 1}
87 assert_response :success
90 assert_response :success
88 assert_template 'index'
89
91
90 assert_equal true, assigns(:all_words)
92 assert_select 'input[name=all_words][checked=checked]'
91 assert_equal false, assigns(:titles_only)
93 assert_select 'input[name=titles_only]:not([checked])'
92 assert assigns(:results).include?(Issue.find(8))
94
93 assert assigns(:results).include?(Issue.find(5))
95 assert_select '#search-results' do
94 assert_select 'dt.issue.closed a', :text => /Closed/
96 assert_select 'dt.issue a', :text => /Bug #5/
97 assert_select 'dt.issue.closed a', :text => /Bug #8 \(Closed\)/
98 end
95 end
99 end
96
100
97 def test_search_issues_should_search_notes
101 def test_search_issues_should_search_notes
@@ -99,7 +103,10 class SearchControllerTest < Redmine::ControllerTest
99
103
100 get :index, :params => {:q => 'searchkeyword', :issues => 1}
104 get :index, :params => {:q => 'searchkeyword', :issues => 1}
101 assert_response :success
105 assert_response :success
102 assert_include Issue.find(2), assigns(:results)
106
107 assert_select '#search-results' do
108 assert_select 'dt.issue a', :text => /Feature request #2/
109 end
103 end
110 end
104
111
105 def test_search_issues_with_multiple_matches_in_journals_should_return_issue_once
112 def test_search_issues_with_multiple_matches_in_journals_should_return_issue_once
@@ -108,8 +115,11 class SearchControllerTest < Redmine::ControllerTest
108
115
109 get :index, :params => {:q => 'searchkeyword', :issues => 1}
116 get :index, :params => {:q => 'searchkeyword', :issues => 1}
110 assert_response :success
117 assert_response :success
111 assert_include Issue.find(2), assigns(:results)
118
112 assert_equal 1, assigns(:results).size
119 assert_select '#search-results' do
120 assert_select 'dt.issue a', :text => /Feature request #2/
121 assert_select 'dt', 1
122 end
113 end
123 end
114
124
115 def test_search_issues_should_search_private_notes_with_permission_only
125 def test_search_issues_should_search_private_notes_with_permission_only
@@ -119,66 +129,74 class SearchControllerTest < Redmine::ControllerTest
119 Role.find(1).add_permission! :view_private_notes
129 Role.find(1).add_permission! :view_private_notes
120 get :index, :params => {:q => 'searchkeyword', :issues => 1}
130 get :index, :params => {:q => 'searchkeyword', :issues => 1}
121 assert_response :success
131 assert_response :success
122 assert_include Issue.find(2), assigns(:results)
132 assert_select '#search-results' do
133 assert_select 'dt.issue a', :text => /Feature request #2/
134 end
123
135
124 Role.find(1).remove_permission! :view_private_notes
136 Role.find(1).remove_permission! :view_private_notes
125 get :index, :params => {:q => 'searchkeyword', :issues => 1}
137 get :index, :params => {:q => 'searchkeyword', :issues => 1}
126 assert_response :success
138 assert_response :success
127 assert_not_include Issue.find(2), assigns(:results)
139 assert_select '#search-results' do
140 assert_select 'dt', :text => /Feature request #2/, :count => 0
141 end
128 end
142 end
129
143
130 def test_search_all_projects_with_scope_param
144 def test_search_all_projects_with_scope_param
131 get :index, :params => {:q => 'issue', :scope => 'all'}
145 get :index, :params => {:q => 'issue', :scope => 'all'}
132 assert_response :success
146 assert_response :success
133 assert_template 'index'
147
134 assert assigns(:results).present?
148 assert_select '#search-results dt'
135 end
149 end
136
150
137 def test_search_my_projects
151 def test_search_my_projects
138 @request.session[:user_id] = 2
152 @request.session[:user_id] = 2
139 get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''}
153 get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''}
140 assert_response :success
154 assert_response :success
141 assert_template 'index'
155
142 assert assigns(:results).include?(Issue.find(1))
156 assert_select '#search-results' do
143 assert !assigns(:results).include?(Issue.find(5))
157 assert_select 'dt.issue', :text => /Bug #1/
158 assert_select 'dt', :text => /Bug #5/, :count => 0
159 end
144 end
160 end
145
161
146 def test_search_my_projects_without_memberships
162 def test_search_my_projects_without_memberships
147 # anonymous user has no memberships
163 # anonymous user has no memberships
148 get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''}
164 get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''}
149 assert_response :success
165 assert_response :success
150 assert_template 'index'
166
151 assert assigns(:results).empty?
167 assert_select '#search-results' do
168 assert_select 'dt', 0
169 end
152 end
170 end
153
171
154 def test_search_project_and_subprojects
172 def test_search_project_and_subprojects
155 get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''}
173 get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''}
156 assert_response :success
174 assert_response :success
157 assert_template 'index'
175
158 assert assigns(:results).include?(Issue.find(1))
176 assert_select '#search-results' do
159 assert assigns(:results).include?(Issue.find(5))
177 assert_select 'dt.issue', :text => /Bug #1/
178 assert_select 'dt.issue', :text => /Bug #5/
179 end
160 end
180 end
161
181
162 def test_search_without_searchable_custom_fields
182 def test_search_without_searchable_custom_fields
163 CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
183 CustomField.update_all :searchable => false
164
184
165 get :index, :params => {:id => 1}
185 get :index, :params => {:id => 1}
166 assert_response :success
186 assert_response :success
167 assert_template 'index'
168 assert_not_nil assigns(:project)
169
187
170 get :index, :params => {:id => 1, :q => "can"}
188 get :index, :params => {:id => 1, :q => "can"}
171 assert_response :success
189 assert_response :success
172 assert_template 'index'
173 end
190 end
174
191
175 def test_search_with_searchable_custom_fields
192 def test_search_with_searchable_custom_fields
176 get :index, :params => {:id => 1, :q => "stringforcustomfield"}
193 get :index, :params => {:id => 1, :q => "stringforcustomfield"}
177 assert_response :success
194 assert_response :success
178 results = assigns(:results)
195
179 assert_not_nil results
196 assert_select '#search-results' do
180 assert_equal 1, results.size
197 assert_select 'dt.issue', :text => /#7/
181 assert results.include?(Issue.find(7))
198 assert_select 'dt', 1
199 end
182 end
200 end
183
201
184 def test_search_without_attachments
202 def test_search_without_attachments
@@ -186,9 +204,12 class SearchControllerTest < Redmine::ControllerTest
186 attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
204 attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
187
205
188 get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '0'}
206 get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '0'}
189 results = assigns(:results)
207 assert_response :success
190 assert_equal 1, results.size
208
191 assert_equal issue, results.first
209 assert_select '#search-results' do
210 assert_select 'dt.issue', :text => /##{issue.id}/
211 assert_select 'dt', 1
212 end
192 end
213 end
193
214
194 def test_search_attachments_only
215 def test_search_attachments_only
@@ -196,18 +217,26 class SearchControllerTest < Redmine::ControllerTest
196 attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
217 attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
197
218
198 get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => 'only'}
219 get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => 'only'}
199 results = assigns(:results)
220 assert_response :success
200 assert_equal 1, results.size
221
201 assert_equal attachment.container, results.first
222 assert_select '#search-results' do
223 assert_select 'dt.issue', :text => / #1 /
224 assert_select 'dt', 1
225 end
202 end
226 end
203
227
204 def test_search_with_attachments
228 def test_search_with_attachments
205 Issue.generate! :subject => 'search_attachments'
229 issue = Issue.generate! :subject => 'search_attachments'
206 Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
230 Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
207
231
208 get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '1'}
232 get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '1'}
209 results = assigns(:results)
233 assert_response :success
210 assert_equal 2, results.size
234
235 assert_select '#search-results' do
236 assert_select 'dt.issue', :text => / #1 /
237 assert_select 'dt.issue', :text => / ##{issue.id} /
238 assert_select 'dt', 2
239 end
211 end
240 end
212
241
213 def test_search_open_issues
242 def test_search_open_issues
@@ -215,78 +244,98 class SearchControllerTest < Redmine::ControllerTest
215 Issue.generate! :subject => 'search_open', :status_id => 5
244 Issue.generate! :subject => 'search_open', :status_id => 5
216
245
217 get :index, :params => {:id => 1, :q => 'search_open', :open_issues => '1'}
246 get :index, :params => {:id => 1, :q => 'search_open', :open_issues => '1'}
218 results = assigns(:results)
247 assert_response :success
219 assert_equal 1, results.size
248
249 assert_select '#search-results' do
250 assert_select 'dt', 1
251 end
220 end
252 end
221
253
222 def test_search_all_words
254 def test_search_all_words
223 # 'all words' is on by default
255 # 'all words' is on by default
224 get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => '1'}
256 get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => '1'}
225 assert_equal true, assigns(:all_words)
257 assert_response :success
226 results = assigns(:results)
258
227 assert_not_nil results
259 assert_select 'input[name=all_words][checked=checked]'
228 assert_equal 1, results.size
260 assert_select '#search-results' do
229 assert results.include?(Issue.find(3))
261 assert_select 'dt.issue', :text => / #3 /
262 assert_select 'dt', 1
263 end
230 end
264 end
231
265
232 def test_search_one_of_the_words
266 def test_search_one_of_the_words
233 get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => ''}
267 get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => ''}
234 assert_equal false, assigns(:all_words)
268 assert_response :success
235 results = assigns(:results)
269
236 assert_not_nil results
270 assert_select 'input[name=all_words]:not([checked])'
237 assert_equal 3, results.size
271 assert_select '#search-results' do
238 assert results.include?(Issue.find(3))
272 assert_select 'dt.issue', :text => / #3 /
273 assert_select 'dt', 3
274 end
239 end
275 end
240
276
241 def test_search_titles_only_without_result
277 def test_search_titles_only_without_result
242 get :index, :params => {:id => 1, :q => 'recipe updating saving', :titles_only => '1'}
278 get :index, :params => {:id => 1, :q => 'recipe updating saving', :titles_only => '1'}
243 results = assigns(:results)
279 assert_response :success
244 assert_not_nil results
280
245 assert_equal 0, results.size
281 assert_select 'input[name=titles_only][checked=checked]'
282 assert_select '#search-results' do
283 assert_select 'dt', 0
284 end
246 end
285 end
247
286
248 def test_search_titles_only
287 def test_search_titles_only
249 get :index, :params => {:id => 1, :q => 'recipe', :titles_only => '1'}
288 get :index, :params => {:id => 1, :q => 'recipe', :titles_only => '1'}
250 assert_equal true, assigns(:titles_only)
289 assert_response :success
251 results = assigns(:results)
290
252 assert_not_nil results
291 assert_select 'input[name=titles_only][checked=checked]'
253 assert_equal 2, results.size
292 assert_select '#search-results' do
293 assert_select 'dt', 2
294 end
254 end
295 end
255
296
256 def test_search_content
297 def test_search_content
257 Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'")
298 Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'")
258
299
259 get :index, :params => {:id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''}
300 get :index, :params => {:id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''}
260 assert_equal false, assigns(:titles_only)
301 assert_response :success
261 results = assigns(:results)
302
262 assert_not_nil results
303 assert_select 'input[name=titles_only]:not([checked])'
263 assert_equal 1, results.size
304 assert_select '#search-results' do
305 assert_select 'dt.issue', :text => / #1 /
306 assert_select 'dt', 1
307 end
264 end
308 end
265
309
266 def test_search_with_pagination
310 def test_search_with_pagination
267 issue = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse
311 issues = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse
268
312
269 get :index, :params => {:q => 'search_with_limited_results'}
313 get :index, :params => {:q => 'search_with_limited_results'}
270 assert_response :success
314 assert_response :success
271 assert_equal issue[0..9], assigns(:results)
315 issues[0..9].each do |issue|
316 assert_select '#search-results dt.issue', :text => / ##{issue.id} /
317 end
272
318
273 get :index, :params => {:q => 'search_with_limited_results', :page => 2}
319 get :index, :params => {:q => 'search_with_limited_results', :page => 2}
274 assert_response :success
320 assert_response :success
275 assert_equal issue[10..19], assigns(:results)
321 issues[10..19].each do |issue|
322 assert_select '#search-results dt.issue', :text => / ##{issue.id} /
323 end
276
324
277 get :index, :params => {:q => 'search_with_limited_results', :page => 3}
325 get :index, :params => {:q => 'search_with_limited_results', :page => 3}
278 assert_response :success
326 assert_response :success
279 assert_equal issue[20..24], assigns(:results)
327 issues[20..24].each do |issue|
328 assert_select '#search-results dt.issue', :text => / ##{issue.id} /
329 end
280
330
281 get :index, :params => {:q => 'search_with_limited_results', :page => 4}
331 get :index, :params => {:q => 'search_with_limited_results', :page => 4}
282 assert_response :success
332 assert_response :success
283 assert_equal [], assigns(:results)
333 assert_select '#search-results dt', 0
284 end
334 end
285
335
286 def test_search_with_invalid_project_id
336 def test_search_with_invalid_project_id
287 get :index, :params => {:id => 195, :q => 'recipe'}
337 get :index, :params => {:id => 195, :q => 'recipe'}
288 assert_response 404
338 assert_response 404
289 assert_nil assigns(:results)
290 end
339 end
291
340
292 def test_quick_jump_to_issue
341 def test_quick_jump_to_issue
@@ -297,18 +346,25 class SearchControllerTest < Redmine::ControllerTest
297 # issue of a private project
346 # issue of a private project
298 get :index, :params => {:q => "4"}
347 get :index, :params => {:q => "4"}
299 assert_response :success
348 assert_response :success
300 assert_template 'index'
301 end
349 end
302
350
303 def test_large_integer
351 def test_large_integer
304 get :index, :params => {:q => '4615713488'}
352 get :index, :params => {:q => '4615713488'}
305 assert_response :success
353 assert_response :success
306 assert_template 'index'
307 end
354 end
308
355
309 def test_tokens_with_quotes
356 def test_tokens_with_quotes
310 get :index, :params => {:id => 1, :q => '"good bye" hello "bye bye"'}
357 issue1 = Issue.generate! :subject => 'say hello'
311 assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens)
358 issue2 = Issue.generate! :subject => 'say good bye'
359 issue3 = Issue.generate! :subject => 'say goodbye'
360
361 get :index, :params => {:q => '"good bye" hello "bye bye"', :all_words => ''}
362 assert_response :success
363 assert_select '#search-results' do
364 assert_select 'dt.issue a', :text => / ##{issue1.id} /
365 assert_select 'dt.issue a', :text => / ##{issue2.id} /
366 assert_select 'dt.issue a', :text => / ##{issue3.id} /, :count => 0
367 end
312 end
368 end
313
369
314 def test_results_should_be_escaped_once
370 def test_results_should_be_escaped_once
@@ -68,9 +68,9 class SearchCustomFieldsVisibilityTest < Redmine::ControllerTest
68 assert_response :success
68 assert_response :success
69 # we should get a result only if the custom field is visible
69 # we should get a result only if the custom field is visible
70 if fields.include?(field)
70 if fields.include?(field)
71 assert_equal 1, assigns(:results).size
71 assert_select '#search-results dt', 1
72 else
72 else
73 assert_equal 0, assigns(:results).size
73 assert_select '#search-results dt', 0
74 end
74 end
75 end
75 end
76 end
76 end
@@ -34,13 +34,13 class SettingsControllerTest < Redmine::ControllerTest
34 def test_index
34 def test_index
35 get :index
35 get :index
36 assert_response :success
36 assert_response :success
37 assert_template 'edit'
37
38 assert_select 'input[name=?][value=?]', 'settings[app_title]', Setting.app_title
38 end
39 end
39
40
40 def test_get_edit
41 def test_get_edit
41 get :edit
42 get :edit
42 assert_response :success
43 assert_response :success
43 assert_template 'edit'
44
44
45 assert_select 'input[name=?][value=""]', 'settings[enabled_scm][]'
45 assert_select 'input[name=?][value=""]', 'settings[enabled_scm][]'
46 end
46 end
@@ -195,7 +195,7 class SettingsControllerTest < Redmine::ControllerTest
195
195
196 get :plugin, :params => {:id => 'foo'}
196 get :plugin, :params => {:id => 'foo'}
197 assert_response :success
197 assert_response :success
198 assert_template 'plugin'
198
199 assert_select 'form[action="/settings/plugin/foo"]' do
199 assert_select 'form[action="/settings/plugin/foo"]' do
200 assert_select 'input[name=?][value=?]', 'settings[sample_setting]', 'Plugin setting value'
200 assert_select 'input[name=?][value=?]', 'settings[sample_setting]', 'Plugin setting value'
201 end
201 end
@@ -37,14 +37,12 class TimeEntryReportsControllerTest < Redmine::ControllerTest
37 def test_report_at_project_level
37 def test_report_at_project_level
38 get :report, :params => {:project_id => 'ecookbook'}
38 get :report, :params => {:project_id => 'ecookbook'}
39 assert_response :success
39 assert_response :success
40 assert_template 'report'
41 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report'
40 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report'
42 end
41 end
43
42
44 def test_report_all_projects
43 def test_report_all_projects
45 get :report
44 get :report
46 assert_response :success
45 assert_response :success
47 assert_template 'report'
48 assert_select 'form#query_form[action=?]', '/time_entries/report'
46 assert_select 'form#query_form[action=?]', '/time_entries/report'
49 end
47 end
50
48
@@ -60,42 +58,32 class TimeEntryReportsControllerTest < Redmine::ControllerTest
60 def test_report_all_projects_one_criteria
58 def test_report_all_projects_one_criteria
61 get :report, :params => {:columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']}
59 get :report, :params => {:columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']}
62 assert_response :success
60 assert_response :success
63 assert_template 'report'
61 assert_select 'tr.total td:last', :text => '8.65'
64 assert_not_nil assigns(:report)
65 assert_equal "8.65", "%.2f" % assigns(:report).total_hours
66 end
62 end
67
63
68 def test_report_all_time
64 def test_report_all_time
69 get :report, :params => {:project_id => 1, :criteria => ['project', 'issue']}
65 get :report, :params => {:project_id => 1, :criteria => ['project', 'issue']}
70 assert_response :success
66 assert_response :success
71 assert_template 'report'
67 assert_select 'tr.total td:last', :text => '162.90'
72 assert_not_nil assigns(:report)
73 assert_equal "162.90", "%.2f" % assigns(:report).total_hours
74 end
68 end
75
69
76 def test_report_all_time_by_day
70 def test_report_all_time_by_day
77 get :report, :params => {:project_id => 1, :criteria => ['project', 'issue'], :columns => 'day'}
71 get :report, :params => {:project_id => 1, :criteria => ['project', 'issue'], :columns => 'day'}
78 assert_response :success
72 assert_response :success
79 assert_template 'report'
73 assert_select 'tr.total td:last', :text => '162.90'
80 assert_not_nil assigns(:report)
81 assert_equal "162.90", "%.2f" % assigns(:report).total_hours
82 assert_select 'th', :text => '2007-03-12'
74 assert_select 'th', :text => '2007-03-12'
83 end
75 end
84
76
85 def test_report_one_criteria
77 def test_report_one_criteria
86 get :report, :params => {:project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']}
78 get :report, :params => {:project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']}
87 assert_response :success
79 assert_response :success
88 assert_template 'report'
80 assert_select 'tr.total td:last', :text => '8.65'
89 assert_not_nil assigns(:report)
90 assert_equal "8.65", "%.2f" % assigns(:report).total_hours
91 end
81 end
92
82
93 def test_report_two_criteria
83 def test_report_two_criteria
94 get :report, :params => {:project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"]}
84 get :report, :params => {:project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"]}
95 assert_response :success
85 assert_response :success
96 assert_template 'report'
86 assert_select 'tr.total td:last', :text => '162.90'
97 assert_not_nil assigns(:report)
98 assert_equal "162.90", "%.2f" % assigns(:report).total_hours
99 end
87 end
100
88
101 def test_report_custom_field_criteria_with_multiple_values_on_single_value_custom_field_should_not_fail
89 def test_report_custom_field_criteria_with_multiple_values_on_single_value_custom_field_should_not_fail
@@ -123,9 +111,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest
123 def test_report_one_day
111 def test_report_one_day
124 get :report, :params => {:project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]}
112 get :report, :params => {:project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]}
125 assert_response :success
113 assert_response :success
126 assert_template 'report'
114 assert_select 'tr.total td:last', :text => '4.25'
127 assert_not_nil assigns(:report)
128 assert_equal "4.25", "%.2f" % assigns(:report).total_hours
129 end
115 end
130
116
131 def test_report_by_week_should_use_commercial_year
117 def test_report_by_week_should_use_commercial_year
@@ -157,7 +143,6 class TimeEntryReportsControllerTest < Redmine::ControllerTest
157 def test_report_should_propose_association_custom_fields
143 def test_report_should_propose_association_custom_fields
158 get :report
144 get :report
159 assert_response :success
145 assert_response :success
160 assert_template 'report'
161
146
162 assert_select 'select[name=?]', 'criteria[]' do
147 assert_select 'select[name=?]', 'criteria[]' do
163 assert_select 'option[value=cf_1]', {:text => 'Database'}, 'Issue custom field not found'
148 assert_select 'option[value=cf_1]', {:text => 'Database'}, 'Issue custom field not found'
@@ -169,10 +154,8 class TimeEntryReportsControllerTest < Redmine::ControllerTest
169 def test_report_with_association_custom_fields
154 def test_report_with_association_custom_fields
170 get :report, :params => {:criteria => ['cf_1', 'cf_3', 'cf_7']}
155 get :report, :params => {:criteria => ['cf_1', 'cf_3', 'cf_7']}
171 assert_response :success
156 assert_response :success
172 assert_template 'report'
157
173 assert_not_nil assigns(:report)
158 assert_select 'tr.total td:last', :text => '162.90'
174 assert_equal 3, assigns(:report).criteria.size
175 assert_equal "162.90", "%.2f" % assigns(:report).total_hours
176
159
177 # Custom fields columns
160 # Custom fields columns
178 assert_select 'th', :text => 'Database'
161 assert_select 'th', :text => 'Database'
@@ -189,15 +172,14 class TimeEntryReportsControllerTest < Redmine::ControllerTest
189 def test_report_one_criteria_no_result
172 def test_report_one_criteria_no_result
190 get :report, :params => {:project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criteria => ['project']}
173 get :report, :params => {:project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criteria => ['project']}
191 assert_response :success
174 assert_response :success
192 assert_template 'report'
175
193 assert_not_nil assigns(:report)
176 assert_select '.nodata'
194 assert_equal "0.00", "%.2f" % assigns(:report).total_hours
195 end
177 end
196
178
197 def test_report_status_criterion
179 def test_report_status_criterion
198 get :report, :params => {:project_id => 1, :criteria => ['status']}
180 get :report, :params => {:project_id => 1, :criteria => ['status']}
199 assert_response :success
181 assert_response :success
200 assert_template 'report'
182
201 assert_select 'th', :text => 'Status'
183 assert_select 'th', :text => 'Status'
202 assert_select 'td', :text => 'New'
184 assert_select 'td', :text => 'New'
203 end
185 end
@@ -32,7 +32,7 class TimelogControllerTest < Redmine::ControllerTest
32 @request.session[:user_id] = 3
32 @request.session[:user_id] = 3
33 get :new
33 get :new
34 assert_response :success
34 assert_response :success
35 assert_template 'new'
35
36 assert_select 'input[name=?][type=hidden]', 'project_id', 0
36 assert_select 'input[name=?][type=hidden]', 'project_id', 0
37 assert_select 'input[name=?][type=hidden]', 'issue_id', 0
37 assert_select 'input[name=?][type=hidden]', 'issue_id', 0
38 assert_select 'select[name=?]', 'time_entry[project_id]' do
38 assert_select 'select[name=?]', 'time_entry[project_id]' do
@@ -45,7 +45,7 class TimelogControllerTest < Redmine::ControllerTest
45 @request.session[:user_id] = 3
45 @request.session[:user_id] = 3
46 get :new, :params => {:project_id => 1}
46 get :new, :params => {:project_id => 1}
47 assert_response :success
47 assert_response :success
48 assert_template 'new'
48
49 assert_select 'input[name=?][type=hidden]', 'project_id'
49 assert_select 'input[name=?][type=hidden]', 'project_id'
50 assert_select 'input[name=?][type=hidden]', 'issue_id', 0
50 assert_select 'input[name=?][type=hidden]', 'issue_id', 0
51 assert_select 'select[name=?]', 'time_entry[project_id]', 0
51 assert_select 'select[name=?]', 'time_entry[project_id]', 0
@@ -55,7 +55,7 class TimelogControllerTest < Redmine::ControllerTest
55 @request.session[:user_id] = 3
55 @request.session[:user_id] = 3
56 get :new, :params => {:issue_id => 2}
56 get :new, :params => {:issue_id => 2}
57 assert_response :success
57 assert_response :success
58 assert_template 'new'
58
59 assert_select 'input[name=?][type=hidden]', 'project_id', 0
59 assert_select 'input[name=?][type=hidden]', 'project_id', 0
60 assert_select 'input[name=?][type=hidden]', 'issue_id'
60 assert_select 'input[name=?][type=hidden]', 'issue_id'
61 assert_select 'select[name=?]', 'time_entry[project_id]', 0
61 assert_select 'select[name=?]', 'time_entry[project_id]', 0
@@ -65,7 +65,7 class TimelogControllerTest < Redmine::ControllerTest
65 @request.session[:user_id] = 3
65 @request.session[:user_id] = 3
66 get :new, :params => {:time_entry => {:project_id => '1'}}
66 get :new, :params => {:time_entry => {:project_id => '1'}}
67 assert_response :success
67 assert_response :success
68 assert_template 'new'
68
69 assert_select 'select[name=?]', 'time_entry[project_id]' do
69 assert_select 'select[name=?]', 'time_entry[project_id]' do
70 assert_select 'option[value="1"][selected=selected]'
70 assert_select 'option[value="1"][selected=selected]'
71 end
71 end
@@ -106,7 +106,7 class TimelogControllerTest < Redmine::ControllerTest
106 @request.session[:user_id] = 2
106 @request.session[:user_id] = 2
107 get :edit, :params => {:id => 2, :project_id => nil}
107 get :edit, :params => {:id => 2, :project_id => nil}
108 assert_response :success
108 assert_response :success
109 assert_template 'edit'
109
110 assert_select 'form[action=?]', '/time_entries/2'
110 assert_select 'form[action=?]', '/time_entries/2'
111 end
111 end
112
112
@@ -118,7 +118,7 class TimelogControllerTest < Redmine::ControllerTest
118 @request.session[:user_id] = 1
118 @request.session[:user_id] = 1
119 get :edit, :params => {:project_id => 1, :id => 1}
119 get :edit, :params => {:project_id => 1, :id => 1}
120 assert_response :success
120 assert_response :success
121 assert_template 'edit'
121
122 # Blank option since nothing is pre-selected
122 # Blank option since nothing is pre-selected
123 assert_select 'option', :text => '--- Please select ---'
123 assert_select 'option', :text => '--- Please select ---'
124 end
124 end
@@ -341,7 +341,7 class TimelogControllerTest < Redmine::ControllerTest
341 post :create, :params => {:time_entry => {:issue_id => ''}}
341 post :create, :params => {:time_entry => {:issue_id => ''}}
342
342
343 assert_response :success
343 assert_response :success
344 assert_template 'new'
344 assert_select_error /Project cannot be blank/
345 end
345 end
346
346
347 def test_create_with_failure
347 def test_create_with_failure
@@ -356,7 +356,6 class TimelogControllerTest < Redmine::ControllerTest
356 }
356 }
357 }
357 }
358 assert_response :success
358 assert_response :success
359 assert_template 'new'
360 end
359 end
361
360
362 def test_create_without_project
361 def test_create_without_project
@@ -393,7 +392,7 class TimelogControllerTest < Redmine::ControllerTest
393 end
392 end
394
393
395 assert_response :success
394 assert_response :success
396 assert assigns(:time_entry).errors[:issue_id].present?
395 assert_select_error /Issue is invalid/
397 end
396 end
398
397
399 def test_create_without_project_should_deny_without_permission
398 def test_create_without_project_should_deny_without_permission
@@ -484,8 +483,8 class TimelogControllerTest < Redmine::ControllerTest
484 :issue_id => '5'
483 :issue_id => '5'
485 }
484 }
486 }
485 }
487 assert_response 200
486 assert_response :success
488 assert_include "Issue is invalid", assigns(:time_entry).errors.full_messages
487 assert_select_error /Issue is invalid/
489 end
488 end
490
489
491 def test_get_bulk_edit
490 def test_get_bulk_edit
@@ -493,7 +492,6 class TimelogControllerTest < Redmine::ControllerTest
493
492
494 get :bulk_edit, :params => {:ids => [1, 2]}
493 get :bulk_edit, :params => {:ids => [1, 2]}
495 assert_response :success
494 assert_response :success
496 assert_template 'bulk_edit'
497
495
498 assert_select 'ul#bulk-selection' do
496 assert_select 'ul#bulk-selection' do
499 assert_select 'li', 2
497 assert_select 'li', 2
@@ -517,7 +515,6 class TimelogControllerTest < Redmine::ControllerTest
517
515
518 get :bulk_edit, :params => {:ids => [1, 2, 6]}
516 get :bulk_edit, :params => {:ids => [1, 2, 6]}
519 assert_response :success
517 assert_response :success
520 assert_template 'bulk_edit'
521 end
518 end
522
519
523 def test_bulk_edit_with_edit_own_time_entries_permission
520 def test_bulk_edit_with_edit_own_time_entries_permission
@@ -664,26 +661,28 class TimelogControllerTest < Redmine::ControllerTest
664 @request.session[:user_id] = 2
661 @request.session[:user_id] = 2
665 get :index
662 get :index
666 assert_response :success
663 assert_response :success
667 assert_template 'index'
664
668 assert_select 'a[href=?]', '/time_entries/new', :text => /Log time/
665 assert_select 'a[href=?]', '/time_entries/new', :text => /Log time/
669 end
666 end
670
667
671 def test_index_my_spent_time
668 def test_index_my_spent_time
672 @request.session[:user_id] = 2
669 @request.session[:user_id] = 2
673 get :index, :params => {:user_id => 'me'}
670 get :index, :params => {:user_id => 'me', :c => ['user']}
674 assert_response :success
671 assert_response :success
675 assert_template 'index'
672
676 assert assigns(:entries).all? {|entry| entry.user_id == 2}
673 users = css_select('table.time-entries tbody td.user').map(&:text).uniq
674 assert_equal ["John Smith"], users
677 end
675 end
678
676
679 def test_index_at_project_level
677 def test_index_at_project_level
680 get :index, :params => {:project_id => 'ecookbook'}
678 get :index, :params => {:project_id => 'ecookbook', :c => ['project']}
681 assert_response :success
679 assert_response :success
682 assert_template 'index'
680
683 assert_not_nil assigns(:entries)
681 assert_select 'tr.time-entry', 4
684 assert_equal 4, assigns(:entries).size
682
685 # project and subproject
683 # project and subproject
686 assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
684 projects = css_select('table.time-entries tbody td.project').map(&:text).uniq.sort
685 assert_equal ["eCookbook", "eCookbook Subproject 1"], projects
687
686
688 assert_select '.total-for-hours', :text => 'Hours: 162.90'
687 assert_select '.total-for-hours', :text => 'Hours: 162.90'
689 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
688 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
@@ -693,10 +692,11 class TimelogControllerTest < Redmine::ControllerTest
693 entry = TimeEntry.generate!(:project => Project.find(3))
692 entry = TimeEntry.generate!(:project => Project.find(3))
694
693
695 with_settings :display_subprojects_issues => '0' do
694 with_settings :display_subprojects_issues => '0' do
696 get :index, :params => {:project_id => 'ecookbook'}
695 get :index, :params => {:project_id => 'ecookbook', :c => ['project']}
697 assert_response :success
696 assert_response :success
698 assert_template 'index'
697
699 assert_not_include entry, assigns(:entries)
698 projects = css_select('table.time-entries tbody td.project').map(&:text).uniq.sort
699 assert_equal ["eCookbook"], projects
700 end
700 end
701 end
701 end
702
702
@@ -704,10 +704,11 class TimelogControllerTest < Redmine::ControllerTest
704 entry = TimeEntry.generate!(:project => Project.find(3))
704 entry = TimeEntry.generate!(:project => Project.find(3))
705
705
706 with_settings :display_subprojects_issues => '0' do
706 with_settings :display_subprojects_issues => '0' do
707 get :index, :params => {:project_id => 'ecookbook', :subproject_id => 3}
707 get :index, :params => {:project_id => 'ecookbook', :c => ['project'], :subproject_id => 3}
708 assert_response :success
708 assert_response :success
709 assert_template 'index'
709
710 assert_include entry, assigns(:entries)
710 projects = css_select('table.time-entries tbody td.project').map(&:text).uniq.sort
711 assert_equal ["eCookbook", "eCookbook Subproject 1"], projects
711 end
712 end
712 end
713 end
713
714
@@ -740,10 +741,8 class TimelogControllerTest < Redmine::ControllerTest
740 :v => {'spent_on' => ['2007-03-20', '2007-04-30']}
741 :v => {'spent_on' => ['2007-03-20', '2007-04-30']}
741 }
742 }
742 assert_response :success
743 assert_response :success
743 assert_template 'index'
744 assert_not_nil assigns(:entries)
745 assert_equal 3, assigns(:entries).size
746
744
745 assert_select 'tr.time-entry', 3
747 assert_select '.total-for-hours', :text => 'Hours: 12.90'
746 assert_select '.total-for-hours', :text => 'Hours: 12.90'
748 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
747 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
749 end
748 end
@@ -755,10 +754,8 class TimelogControllerTest < Redmine::ControllerTest
755 :to => '2007-04-30'
754 :to => '2007-04-30'
756 }
755 }
757 assert_response :success
756 assert_response :success
758 assert_template 'index'
759 assert_not_nil assigns(:entries)
760 assert_equal 3, assigns(:entries).size
761
757
758 assert_select 'tr.time-entry', 3
762 assert_select '.total-for-hours', :text => 'Hours: 12.90'
759 assert_select '.total-for-hours', :text => 'Hours: 12.90'
763 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
760 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
764 end
761 end
@@ -787,7 +784,7 class TimelogControllerTest < Redmine::ControllerTest
787 :v => {'spent_on' => ['2012-06-15', '2012-06-16']}
784 :v => {'spent_on' => ['2012-06-15', '2012-06-16']}
788 }
785 }
789 assert_response :success
786 assert_response :success
790 assert_equal [t2, t1, t3], assigns(:entries)
787 assert_equal [t2, t1, t3].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')}
791
788
792 get :index, :params => {
789 get :index, :params => {
793 :project_id => 1,
790 :project_id => 1,
@@ -797,7 +794,7 class TimelogControllerTest < Redmine::ControllerTest
797 :sort => 'spent_on'
794 :sort => 'spent_on'
798 }
795 }
799 assert_response :success
796 assert_response :success
800 assert_equal [t3, t1, t2], assigns(:entries)
797 assert_equal [t3, t1, t2].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')}
801 end
798 end
802
799
803 def test_index_with_filter_on_issue_custom_field
800 def test_index_with_filter_on_issue_custom_field
@@ -810,7 +807,7 class TimelogControllerTest < Redmine::ControllerTest
810 :v => {'issue.cf_2' => ['filter_on_issue_custom_field']}
807 :v => {'issue.cf_2' => ['filter_on_issue_custom_field']}
811 }
808 }
812 assert_response :success
809 assert_response :success
813 assert_equal [entry], assigns(:entries)
810 assert_equal [entry].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')}
814 end
811 end
815
812
816 def test_index_with_issue_custom_field_column
813 def test_index_with_issue_custom_field_column
@@ -821,7 +818,6 class TimelogControllerTest < Redmine::ControllerTest
821 :c => %w(project spent_on issue comments hours issue.cf_2)
818 :c => %w(project spent_on issue comments hours issue.cf_2)
822 }
819 }
823 assert_response :success
820 assert_response :success
824 assert_include :'issue.cf_2', assigns(:query).column_names
825 assert_select 'td.issue_cf_2', :text => 'filter_on_issue_custom_field'
821 assert_select 'td.issue_cf_2', :text => 'filter_on_issue_custom_field'
826 end
822 end
827
823
@@ -834,7 +830,6 class TimelogControllerTest < Redmine::ControllerTest
834 :c => ["hours", field_name]
830 :c => ["hours", field_name]
835 }
831 }
836 assert_response :success
832 assert_response :success
837 assert_include field_name.to_sym, assigns(:query).column_names
838 assert_select "td.#{field_name}", :text => 'CF Value'
833 assert_select "td.#{field_name}", :text => 'CF Value'
839 end
834 end
840
835
@@ -850,13 +845,12 class TimelogControllerTest < Redmine::ControllerTest
850 :sort => field_name
845 :sort => field_name
851 }
846 }
852 assert_response :success
847 assert_response :success
853 assert_include field_name.to_sym, assigns(:query).column_names
854 assert_select "th a.sort", :text => 'String Field'
848 assert_select "th a.sort", :text => 'String Field'
855
849
856 # Make sure that values are properly sorted
850 # Make sure that values are properly sorted
857 values = assigns(:entries).map {|e| e.custom_field_value(field)}.compact
851 values = css_select("td.#{field_name}").map(&:text).reject(&:blank?)
858 assert_equal 3, values.size
859 assert_equal values.sort, values
852 assert_equal values.sort, values
853 assert_equal 3, values.size
860 end
854 end
861
855
862 def test_index_with_query
856 def test_index_with_query
@@ -874,8 +868,7 class TimelogControllerTest < Redmine::ControllerTest
874 get :index, :params => {:project_id => 1, :format => 'atom'}
868 get :index, :params => {:project_id => 1, :format => 'atom'}
875 assert_response :success
869 assert_response :success
876 assert_equal 'application/atom+xml', @response.content_type
870 assert_equal 'application/atom+xml', @response.content_type
877 assert_not_nil assigns(:items)
871 assert_select 'entry > title', :text => /7\.65 hours/
878 assert assigns(:items).first.is_a?(TimeEntry)
879 end
872 end
880
873
881 def test_index_at_project_level_should_include_csv_export_dialog
874 def test_index_at_project_level_should_include_csv_export_dialog
@@ -122,7 +122,9 class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest
122 assert_select 'td', :text => 'ValueB', :count => 0
122 assert_select 'td', :text => 'ValueB', :count => 0
123 assert_select 'td', {:text => 'ValueC'}, "ValueC not found in:\n#{response.body}"
123 assert_select 'td', {:text => 'ValueC'}, "ValueC not found in:\n#{response.body}"
124
124
125 get :index, :params => {:set_filter => '1', "issue.cf_#{@field2.id}" => '*'}
125 get :index, :params => {:set_filter => '1', "issue.cf_#{@field2.id}" => '*', :c => ["issue.cf_#{@field2.id}"]}
126 assert_equal %w(ValueA ValueC), assigns(:entries).map{|i| i.issue.custom_field_value(@field2)}.sort
126 assert_select 'td', :text => "ValueA"
127 assert_select 'td', :text => "ValueC"
128 assert_select 'td', :text => "ValueB", :count => 0
127 end
129 end
128 end
130 end
@@ -28,7 +28,7 class TrackersControllerTest < Redmine::ControllerTest
28 def test_index
28 def test_index
29 get :index
29 get :index
30 assert_response :success
30 assert_response :success
31 assert_template 'index'
31 assert_select 'table.trackers'
32 end
32 end
33
33
34 def test_index_by_anonymous_should_redirect_to_login_form
34 def test_index_by_anonymous_should_redirect_to_login_form
@@ -46,7 +46,7 class TrackersControllerTest < Redmine::ControllerTest
46 def test_new
46 def test_new
47 get :new
47 get :new
48 assert_response :success
48 assert_response :success
49 assert_template 'new'
49 assert_select 'input[name=?]', 'tracker[name]'
50 end
50 end
51
51
52 def test_create
52 def test_create
@@ -112,7 +112,6 class TrackersControllerTest < Redmine::ControllerTest
112 }
112 }
113 end
113 end
114 assert_response :success
114 assert_response :success
115 assert_template 'new'
116 assert_select_error /name cannot be blank/i
115 assert_select_error /name cannot be blank/i
117 end
116 end
118
117
@@ -121,7 +120,6 class TrackersControllerTest < Redmine::ControllerTest
121
120
122 get :edit, :params => {:id => 1}
121 get :edit, :params => {:id => 1}
123 assert_response :success
122 assert_response :success
124 assert_template 'edit'
125
123
126 assert_select 'input[name=?][value="1"][checked=checked]', 'tracker[project_ids][]'
124 assert_select 'input[name=?][value="1"][checked=checked]', 'tracker[project_ids][]'
127 assert_select 'input[name=?][value="2"]:not([checked])', 'tracker[project_ids][]'
125 assert_select 'input[name=?][value="2"]:not([checked])', 'tracker[project_ids][]'
@@ -136,7 +134,6 class TrackersControllerTest < Redmine::ControllerTest
136
134
137 get :edit, :params => {:id => 1}
135 get :edit, :params => {:id => 1}
138 assert_response :success
136 assert_response :success
139 assert_template 'edit'
140
137
141 assert_select 'input[name=?][value=assigned_to_id][checked=checked]', 'tracker[core_fields][]'
138 assert_select 'input[name=?][value=assigned_to_id][checked=checked]', 'tracker[core_fields][]'
142 assert_select 'input[name=?][value=fixed_version_id][checked=checked]', 'tracker[core_fields][]'
139 assert_select 'input[name=?][value=fixed_version_id][checked=checked]', 'tracker[core_fields][]'
@@ -186,7 +183,7 class TrackersControllerTest < Redmine::ControllerTest
186 def test_update_with_failure
183 def test_update_with_failure
187 put :update, :params => {:id => 1, :tracker => { :name => '' }}
184 put :update, :params => {:id => 1, :tracker => { :name => '' }}
188 assert_response :success
185 assert_response :success
189 assert_template 'edit'
186
190 assert_select_error /name cannot be blank/i
187 assert_select_error /name cannot be blank/i
191 end
188 end
192
189
@@ -216,7 +213,6 class TrackersControllerTest < Redmine::ControllerTest
216 def test_get_fields
213 def test_get_fields
217 get :fields
214 get :fields
218 assert_response :success
215 assert_response :success
219 assert_template 'fields'
220
216
221 assert_select 'form' do
217 assert_select 'form' do
222 assert_select 'input[type=checkbox][name=?][value=assigned_to_id]', 'trackers[1][core_fields][]'
218 assert_select 'input[type=checkbox][name=?][value=assigned_to_id]', 'trackers[1][core_fields][]'
@@ -35,37 +35,30 class UsersControllerTest < Redmine::ControllerTest
35 def test_index
35 def test_index
36 get :index
36 get :index
37 assert_response :success
37 assert_response :success
38 assert_template 'index'
38 assert_select 'table.users'
39 assert_not_nil assigns(:users)
39 assert_select 'tr.user.active'
40 # active users only
40 assert_select 'tr.user.locked', 0
41 assert_nil assigns(:users).detect {|u| !u.active?}
42 end
41 end
43
42
44 def test_index_with_status_filter
43 def test_index_with_status_filter
45 get :index, :params => {:status => 3}
44 get :index, :params => {:status => 3}
46 assert_response :success
45 assert_response :success
47 assert_template 'index'
46 assert_select 'tr.user.active', 0
48 assert_not_nil assigns(:users)
47 assert_select 'tr.user.locked'
49 assert_equal [3], assigns(:users).map(&:status).uniq
50 end
48 end
51
49
52 def test_index_with_name_filter
50 def test_index_with_name_filter
53 get :index, :params => {:name => 'john'}
51 get :index, :params => {:name => 'john'}
54 assert_response :success
52 assert_response :success
55 assert_template 'index'
53 assert_select 'tr.user td.username', :text => 'jsmith'
56 users = assigns(:users)
54 assert_select 'tr.user', 1
57 assert_not_nil users
58 assert_equal 1, users.size
59 assert_equal 'John', users.first.firstname
60 end
55 end
61
56
62 def test_index_with_group_filter
57 def test_index_with_group_filter
63 get :index, :params => {:group_id => '10'}
58 get :index, :params => {:group_id => '10'}
64 assert_response :success
59 assert_response :success
65 assert_template 'index'
60
66 users = assigns(:users)
61 assert_select 'tr.user', Group.find(10).users.count
67 assert users.any?
68 assert_equal([], (users - Group.find(10).users))
69 assert_select 'select[name=group_id]' do
62 assert_select 'select[name=group_id]' do
70 assert_select 'option[value="10"][selected=selected]'
63 assert_select 'option[value="10"][selected=selected]'
71 end
64 end
@@ -75,8 +68,14 class UsersControllerTest < Redmine::ControllerTest
75 @request.session[:user_id] = nil
68 @request.session[:user_id] = nil
76 get :show, :params => {:id => 2}
69 get :show, :params => {:id => 2}
77 assert_response :success
70 assert_response :success
78 assert_template 'show'
71 assert_select 'h2', :text => /John Smith/
79 assert_not_nil assigns(:user)
72 end
73
74 def test_show_should_display_visible_custom_fields
75 @request.session[:user_id] = nil
76 UserCustomField.find_by_name('Phone number').update_attribute :visible, true
77 get :show, :params => {:id => 2}
78 assert_response :success
80
79
81 assert_select 'li', :text => /Phone number/
80 assert_select 'li', :text => /Phone number/
82 end
81 end
@@ -86,8 +85,6 class UsersControllerTest < Redmine::ControllerTest
86 UserCustomField.find_by_name('Phone number').update_attribute :visible, false
85 UserCustomField.find_by_name('Phone number').update_attribute :visible, false
87 get :show, :params => {:id => 2}
86 get :show, :params => {:id => 2}
88 assert_response :success
87 assert_response :success
89 assert_template 'show'
90 assert_not_nil assigns(:user)
91
88
92 assert_select 'li', :text => /Phone number/, :count => 0
89 assert_select 'li', :text => /Phone number/, :count => 0
93 end
90 end
@@ -113,7 +110,7 class UsersControllerTest < Redmine::ControllerTest
113 @request.session[:user_id] = 1
110 @request.session[:user_id] = 1
114 get :show, :params => {:id => 5}
111 get :show, :params => {:id => 5}
115 assert_response 200
112 assert_response 200
116 assert_not_nil assigns(:user)
113 assert_select 'h2', :text => /Dave2 Lopper2/
117 end
114 end
118
115
119 def test_show_user_who_is_not_visible_should_return_404
116 def test_show_user_who_is_not_visible_should_return_404
@@ -129,10 +126,9 class UsersControllerTest < Redmine::ControllerTest
129 @request.session[:user_id] = 1
126 @request.session[:user_id] = 1
130 get :show, :params => {:id => 2}
127 get :show, :params => {:id => 2}
131 assert_response :success
128 assert_response :success
132 memberships = assigns(:memberships)
129
133 assert_not_nil memberships
130 # membership of private project admin can see
134 project_ids = memberships.map(&:project_id)
131 assert_select 'li a', :text => "OnlineStore"
135 assert project_ids.include?(2) #private project admin can see
136 end
132 end
137
133
138 def test_show_current_should_require_authentication
134 def test_show_current_should_require_authentication
@@ -145,15 +141,13 class UsersControllerTest < Redmine::ControllerTest
145 @request.session[:user_id] = 2
141 @request.session[:user_id] = 2
146 get :show, :params => {:id => 'current'}
142 get :show, :params => {:id => 'current'}
147 assert_response :success
143 assert_response :success
148 assert_template 'show'
144 assert_select 'h2', :text => /John Smith/
149 assert_equal User.find(2), assigns(:user)
150 end
145 end
151
146
152 def test_new
147 def test_new
153 get :new
148 get :new
154 assert_response :success
149 assert_response :success
155 assert_template :new
150 assert_select 'input[name=?]', 'user[login]'
156 assert assigns(:user)
157 end
151 end
158
152
159 def test_create
153 def test_create
@@ -266,7 +260,7 class UsersControllerTest < Redmine::ControllerTest
266 post :create, :params => {:user => {}}
260 post :create, :params => {:user => {}}
267 end
261 end
268 assert_response :success
262 assert_response :success
269 assert_template 'new'
263 assert_select_error /Email cannot be blank/
270 end
264 end
271
265
272 def test_create_with_failure_sould_preserve_preference
266 def test_create_with_failure_sould_preserve_preference
@@ -283,7 +277,6 class UsersControllerTest < Redmine::ControllerTest
283 }
277 }
284 end
278 end
285 assert_response :success
279 assert_response :success
286 assert_template 'new'
287
280
288 assert_select 'select#pref_time_zone option[selected=selected]', :text => /Paris/
281 assert_select 'select#pref_time_zone option[selected=selected]', :text => /Paris/
289 assert_select 'input#pref_no_self_notified[value="1"][checked=checked]'
282 assert_select 'input#pref_no_self_notified[value="1"][checked=checked]'
@@ -336,8 +329,7 class UsersControllerTest < Redmine::ControllerTest
336 def test_edit
329 def test_edit
337 get :edit, :params => {:id => 2}
330 get :edit, :params => {:id => 2}
338 assert_response :success
331 assert_response :success
339 assert_template 'edit'
332 assert_select 'input[name=?][value=?]', 'user[login]', 'jsmith'
340 assert_equal User.find(2), assigns(:user)
341 end
333 end
342
334
343 def test_edit_registered_user
335 def test_edit_registered_user
@@ -371,7 +363,7 class UsersControllerTest < Redmine::ControllerTest
371 }
363 }
372 end
364 end
373 assert_response :success
365 assert_response :success
374 assert_template 'edit'
366 assert_select_error /First name cannot be blank/
375 end
367 end
376
368
377 def test_update_with_group_ids_should_assign_groups
369 def test_update_with_group_ids_should_assign_groups
@@ -476,7 +468,6 class UsersControllerTest < Redmine::ControllerTest
476 def test_update_notified_project
468 def test_update_notified_project
477 get :edit, :params => {:id => 2}
469 get :edit, :params => {:id => 2}
478 assert_response :success
470 assert_response :success
479 assert_template 'edit'
480 u = User.find(2)
471 u = User.find(2)
481 assert_equal [1, 2, 5], u.projects.collect{|p| p.id}.sort
472 assert_equal [1, 2, 5], u.projects.collect{|p| p.id}.sort
482 assert_equal [1, 2, 5], u.notified_projects_ids.sort
473 assert_equal [1, 2, 5], u.notified_projects_ids.sort
@@ -29,12 +29,12 class VersionsControllerTest < Redmine::ControllerTest
29 def test_index
29 def test_index
30 get :index, :params => {:project_id => 1}
30 get :index, :params => {:project_id => 1}
31 assert_response :success
31 assert_response :success
32 assert_template 'index'
32
33 assert_not_nil assigns(:versions)
34 # Version with no date set appears
33 # Version with no date set appears
35 assert assigns(:versions).include?(Version.find(3))
34 assert_select 'h3', :text => Version.find(3).name
36 # Completed version doesn't appear
35 # Completed version doesn't appear
37 assert !assigns(:versions).include?(Version.find(1))
36 assert_select 'h3', :text => Version.find(1).name, :count => 0
37
38 # Context menu on issues
38 # Context menu on issues
39 assert_select "script", :text => Regexp.new(Regexp.escape("contextMenuInit('/issues/context_menu')"))
39 assert_select "script", :text => Regexp.new(Regexp.escape("contextMenuInit('/issues/context_menu')"))
40 assert_select "div#sidebar" do
40 assert_select "div#sidebar" do
@@ -48,31 +48,33 class VersionsControllerTest < Redmine::ControllerTest
48 def test_index_with_completed_versions
48 def test_index_with_completed_versions
49 get :index, :params => {:project_id => 1, :completed => 1}
49 get :index, :params => {:project_id => 1, :completed => 1}
50 assert_response :success
50 assert_response :success
51 assert_template 'index'
51
52 assert_not_nil assigns(:versions)
53 # Version with no date set appears
52 # Version with no date set appears
54 assert assigns(:versions).include?(Version.find(3))
53 assert_select 'h3', :text => Version.find(3).name
55 # Completed version appears
54 # Completed version appears
56 assert assigns(:versions).include?(Version.find(1))
55 assert_select 'h3', :text => Version.find(1).name
57 end
56 end
58
57
59 def test_index_with_tracker_ids
58 def test_index_with_tracker_ids
59 (1..3).each do |tracker_id|
60 Issue.generate! :project_id => 1, :fixed_version_id => 3, :tracker_id => tracker_id
61 end
60 get :index, :params => {:project_id => 1, :tracker_ids => [1, 3]}
62 get :index, :params => {:project_id => 1, :tracker_ids => [1, 3]}
61 assert_response :success
63 assert_response :success
62 assert_template 'index'
64 assert_select 'a.issue.tracker-1'
63 assert_not_nil assigns(:issues_by_version)
65 assert_select 'a.issue.tracker-2', 0
64 assert_nil assigns(:issues_by_version).values.flatten.detect {|issue| issue.tracker_id == 2}
66 assert_select 'a.issue.tracker-3'
65 end
67 end
66
68
67 def test_index_showing_subprojects_versions
69 def test_index_showing_subprojects_versions
68 @subproject_version = Version.create!(:project => Project.find(3), :name => "Subproject version")
70 @subproject_version = Version.create!(:project => Project.find(3), :name => "Subproject version")
69 get :index, :params => {:project_id => 1, :with_subprojects => 1}
71 get :index, :params => {:project_id => 1, :with_subprojects => 1}
70 assert_response :success
72 assert_response :success
71 assert_template 'index'
72 assert_not_nil assigns(:versions)
73
73
74 assert assigns(:versions).include?(Version.find(4)), "Shared version not found"
74 # Shared version
75 assert assigns(:versions).include?(@subproject_version), "Subproject version not found"
75 assert_select 'h3', :text => Version.find(4).name
76 # Subproject version
77 assert_select 'h3', :text => /Subproject version/
76 end
78 end
77
79
78 def test_index_should_prepend_shared_versions
80 def test_index_should_prepend_shared_versions
@@ -92,8 +94,6 class VersionsControllerTest < Redmine::ControllerTest
92 def test_show
94 def test_show
93 get :show, :params => {:id => 2}
95 get :show, :params => {:id => 2}
94 assert_response :success
96 assert_response :success
95 assert_template 'show'
96 assert_not_nil assigns(:version)
97
97
98 assert_select 'h2', :text => /1.0/
98 assert_select 'h2', :text => /1.0/
99 end
99 end
@@ -127,14 +127,13 class VersionsControllerTest < Redmine::ControllerTest
127 @request.session[:user_id] = 2
127 @request.session[:user_id] = 2
128 get :new, :params => {:project_id => '1'}
128 get :new, :params => {:project_id => '1'}
129 assert_response :success
129 assert_response :success
130 assert_template 'new'
130 assert_select 'input[name=?]', 'version[name]'
131 end
131 end
132
132
133 def test_new_from_issue_form
133 def test_new_from_issue_form
134 @request.session[:user_id] = 2
134 @request.session[:user_id] = 2
135 xhr :get, :new, :params => {:project_id => '1'}
135 xhr :get, :new, :params => {:project_id => '1'}
136 assert_response :success
136 assert_response :success
137 assert_template 'new'
138 assert_equal 'text/javascript', response.content_type
137 assert_equal 'text/javascript', response.content_type
139 end
138 end
140
139
@@ -159,7 +158,6 class VersionsControllerTest < Redmine::ControllerTest
159 assert_equal 1, version.project_id
158 assert_equal 1, version.project_id
160
159
161 assert_response :success
160 assert_response :success
162 assert_template 'create'
163 assert_equal 'text/javascript', response.content_type
161 assert_equal 'text/javascript', response.content_type
164 assert_include 'test_add_version_from_issue_form', response.body
162 assert_include 'test_add_version_from_issue_form', response.body
165 end
163 end
@@ -170,7 +168,6 class VersionsControllerTest < Redmine::ControllerTest
170 xhr :post, :create, :params => {:project_id => '1', :version => {:name => ''}}
168 xhr :post, :create, :params => {:project_id => '1', :version => {:name => ''}}
171 end
169 end
172 assert_response :success
170 assert_response :success
173 assert_template 'new'
174 assert_equal 'text/javascript', response.content_type
171 assert_equal 'text/javascript', response.content_type
175 end
172 end
176
173
@@ -178,7 +175,7 class VersionsControllerTest < Redmine::ControllerTest
178 @request.session[:user_id] = 2
175 @request.session[:user_id] = 2
179 get :edit, :params => {:id => 2}
176 get :edit, :params => {:id => 2}
180 assert_response :success
177 assert_response :success
181 assert_template 'edit'
178 assert_select 'input[name=?][value=?]', 'version[name]', Version.find(2).name
182 end
179 end
183
180
184 def test_close_completed
181 def test_close_completed
@@ -216,7 +213,7 class VersionsControllerTest < Redmine::ControllerTest
216 }
213 }
217 }
214 }
218 assert_response :success
215 assert_response :success
219 assert_template 'edit'
216 assert_select_error /Name cannot be blank/
220 end
217 end
221
218
222 def test_destroy
219 def test_destroy
@@ -243,15 +240,11 class VersionsControllerTest < Redmine::ControllerTest
243 def test_issue_status_by
240 def test_issue_status_by
244 xhr :get, :status_by, :params => {:id => 2}
241 xhr :get, :status_by, :params => {:id => 2}
245 assert_response :success
242 assert_response :success
246 assert_template 'status_by'
247 assert_template '_issue_counts'
248 end
243 end
249
244
250 def test_issue_status_by_status
245 def test_issue_status_by_status
251 xhr :get, :status_by, :params => {:id => 2, :status_by => 'status'}
246 xhr :get, :status_by, :params => {:id => 2, :status_by => 'status'}
252 assert_response :success
247 assert_response :success
253 assert_template 'status_by'
254 assert_template '_issue_counts'
255 assert_include 'Assigned', response.body
248 assert_include 'Assigned', response.body
256 assert_include 'Closed', response.body
249 assert_include 'Closed', response.body
257 end
250 end
@@ -144,7 +144,6 class WatchersControllerTest < Redmine::ControllerTest
144 @request.session[:user_id] = 2
144 @request.session[:user_id] = 2
145 xhr :get, :new, :params => {:project_id => 1}
145 xhr :get, :new, :params => {:project_id => 1}
146 assert_response :success
146 assert_response :success
147 assert_equal Project.find(1), assigns(:project)
148 assert_match /ajax-modal/, response.body
147 assert_match /ajax-modal/, response.body
149 end
148 end
150
149
@@ -152,7 +151,6 class WatchersControllerTest < Redmine::ControllerTest
152 @request.session[:user_id] = 2
151 @request.session[:user_id] = 2
153 xhr :get, :new, :params => {:project_id => 'ecookbook'}
152 xhr :get, :new, :params => {:project_id => 'ecookbook'}
154 assert_response :success
153 assert_response :success
155 assert_equal Project.find(1), assigns(:project)
156 assert_match /ajax-modal/, response.body
154 assert_match /ajax-modal/, response.body
157 end
155 end
158
156
@@ -266,16 +264,16 class WatchersControllerTest < Redmine::ControllerTest
266 def test_autocomplete_for_user_should_return_visible_users
264 def test_autocomplete_for_user_should_return_visible_users
267 Role.update_all :users_visibility => 'members_of_visible_projects'
265 Role.update_all :users_visibility => 'members_of_visible_projects'
268
266
269 hidden = User.generate!(:lastname => 'autocomplete')
267 hidden = User.generate!(:lastname => 'autocomplete_hidden')
270 visible = User.generate!(:lastname => 'autocomplete')
268 visible = User.generate!(:lastname => 'autocomplete_visible')
271 User.add_to_project(visible, Project.find(1))
269 User.add_to_project(visible, Project.find(1))
272
270
273 @request.session[:user_id] = 2
271 @request.session[:user_id] = 2
274 xhr :get, :autocomplete_for_user, :params => {:q => 'autocomp', :project_id => 'ecookbook'}
272 xhr :get, :autocomplete_for_user, :params => {:q => 'autocomp', :project_id => 'ecookbook'}
275 assert_response :success
273 assert_response :success
276
274
277 assert_include visible, assigns(:users)
275 assert_include visible.name, response.body
278 assert_not_include hidden, assigns(:users)
276 assert_not_include hidden.name, response.body
279 end
277 end
280
278
281 def test_append
279 def test_append
@@ -28,33 +28,32 class WelcomeControllerTest < Redmine::ControllerTest
28 def test_index
28 def test_index
29 get :index
29 get :index
30 assert_response :success
30 assert_response :success
31 assert_template 'index'
31 assert_select 'h3', :text => 'Latest news'
32 assert_not_nil assigns(:news)
33 end
32 end
34
33
35 def test_browser_language
34 def test_browser_language
36 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
35 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
37 get :index
36 get :index
38 assert_equal :fr, @controller.current_language
37 assert_select 'html[lang=fr]'
39 end
38 end
40
39
41 def test_browser_language_alternate
40 def test_browser_language_alternate
42 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'zh-TW'
41 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'zh-TW'
43 get :index
42 get :index
44 assert_equal :"zh-TW", @controller.current_language
43 assert_select 'html[lang=zh-TW]'
45 end
44 end
46
45
47 def test_browser_language_alternate_not_valid
46 def test_browser_language_alternate_not_valid
48 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr-CA'
47 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr-CA'
49 get :index
48 get :index
50 assert_equal :fr, @controller.current_language
49 assert_select 'html[lang=fr]'
51 end
50 end
52
51
53 def test_browser_language_should_be_ignored_with_force_default_language_for_anonymous
52 def test_browser_language_should_be_ignored_with_force_default_language_for_anonymous
54 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
53 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
55 with_settings :force_default_language_for_anonymous => '1' do
54 with_settings :force_default_language_for_anonymous => '1' do
56 get :index
55 get :index
57 assert_equal :en, @controller.current_language
56 assert_select 'html[lang=en]'
58 end
57 end
59 end
58 end
60
59
@@ -64,7 +63,7 class WelcomeControllerTest < Redmine::ControllerTest
64 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
63 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
65 with_settings :default_language => 'fi' do
64 with_settings :default_language => 'fi' do
66 get :index
65 get :index
67 assert_equal :it, @controller.current_language
66 assert_select 'html[lang=it]'
68 end
67 end
69 end
68 end
70
69
@@ -74,7 +73,7 class WelcomeControllerTest < Redmine::ControllerTest
74 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
73 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
75 with_settings :force_default_language_for_loggedin => '1', :default_language => 'fi' do
74 with_settings :force_default_language_for_loggedin => '1', :default_language => 'fi' do
76 get :index
75 get :index
77 assert_equal :fi, @controller.current_language
76 assert_select 'html[lang=fi]'
78 end
77 end
79 end
78 end
80
79
@@ -30,9 +30,8 class WikiControllerTest < Redmine::ControllerTest
30 def test_show_start_page
30 def test_show_start_page
31 get :show, :params => {:project_id => 'ecookbook'}
31 get :show, :params => {:project_id => 'ecookbook'}
32 assert_response :success
32 assert_response :success
33 assert_template 'show'
34 assert_select 'h1', :text => /CookBook documentation/
35
33
34 assert_select 'h1', :text => /CookBook documentation/
36 # child_pages macro
35 # child_pages macro
37 assert_select 'ul.pages-hierarchy>li>a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image',
36 assert_select 'ul.pages-hierarchy>li>a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image',
38 :text => 'Page with an inline image'
37 :text => 'Page with an inline image'
@@ -48,7 +47,7 class WikiControllerTest < Redmine::ControllerTest
48 def test_show_page_with_name
47 def test_show_page_with_name
49 get :show, :params => {:project_id => 1, :id => 'Another_page'}
48 get :show, :params => {:project_id => 1, :id => 'Another_page'}
50 assert_response :success
49 assert_response :success
51 assert_template 'show'
50
52 assert_select 'h1', :text => /Another page/
51 assert_select 'h1', :text => /Another page/
53 # Included page with an inline image
52 # Included page with an inline image
54 assert_select 'p', :text => /This is an inline image/
53 assert_select 'p', :text => /This is an inline image/
@@ -60,7 +59,6 class WikiControllerTest < Redmine::ControllerTest
60 get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'}
59 get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'}
61 end
60 end
62 assert_response :success
61 assert_response :success
63 assert_template 'show'
64
62
65 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/1', :text => /Previous/
63 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/1', :text => /Previous/
66 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/2/diff', :text => /diff/
64 assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/2/diff', :text => /diff/
@@ -76,9 +74,8 class WikiControllerTest < Redmine::ControllerTest
76 content.save!
74 content.save!
77
75
78 get :show, :params => {:project_id => 'ecookbook', :id => page.title, :version => '1'}
76 get :show, :params => {:project_id => 'ecookbook', :id => page.title, :version => '1'}
79 assert_kind_of WikiContent::Version, assigns(:content)
80 assert_response :success
77 assert_response :success
81 assert_template 'show'
78 assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image', :text => /Current version/
82 end
79 end
83
80
84 def test_show_old_version_without_permission_should_be_denied
81 def test_show_old_version_without_permission_should_be_denied
@@ -93,7 +90,6 class WikiControllerTest < Redmine::ControllerTest
93 get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '1'}
90 get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '1'}
94 end
91 end
95 assert_response :success
92 assert_response :success
96 assert_template 'show'
97
93
98 assert_select 'a', :text => /Previous/, :count => 0
94 assert_select 'a', :text => /Previous/, :count => 0
99 assert_select 'a', :text => /diff/, :count => 0
95 assert_select 'a', :text => /diff/, :count => 0
@@ -150,7 +146,7 class WikiControllerTest < Redmine::ControllerTest
150 @request.session[:user_id] = 2
146 @request.session[:user_id] = 2
151 get :show, :params => {:project_id => 1, :id => 'Unexistent page'}
147 get :show, :params => {:project_id => 1, :id => 'Unexistent page'}
152 assert_response :success
148 assert_response :success
153 assert_template 'edit'
149 assert_select 'textarea[name=?]', 'content[text]'
154 end
150 end
155
151
156 def test_show_specific_version_of_an_unexistent_page_without_edit_right
152 def test_show_specific_version_of_an_unexistent_page_without_edit_right
@@ -162,7 +158,6 class WikiControllerTest < Redmine::ControllerTest
162 @request.session[:user_id] = 2
158 @request.session[:user_id] = 2
163 get :show, :params => {:project_id => 1, :id => 'Unexistent page', :parent => 'Another_page'}
159 get :show, :params => {:project_id => 1, :id => 'Unexistent page', :parent => 'Another_page'}
164 assert_response :success
160 assert_response :success
165 assert_template 'edit'
166 assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]'
161 assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]'
167 end
162 end
168
163
@@ -179,7 +174,6 class WikiControllerTest < Redmine::ControllerTest
179
174
180 get :show, :params => {:project_id => 1, :id => 'NoContent'}
175 get :show, :params => {:project_id => 1, :id => 'NoContent'}
181 assert_response :success
176 assert_response :success
182 assert_template 'edit'
183 assert_select 'textarea[name=?]', 'content[text]'
177 assert_select 'textarea[name=?]', 'content[text]'
184 end
178 end
185
179
@@ -188,7 +182,7 class WikiControllerTest < Redmine::ControllerTest
188
182
189 get :new, :params => {:project_id => 'ecookbook'}
183 get :new, :params => {:project_id => 'ecookbook'}
190 assert_response :success
184 assert_response :success
191 assert_template 'new'
185 assert_select 'input[name=?]', 'title'
192 end
186 end
193
187
194 def test_get_new_xhr
188 def test_get_new_xhr
@@ -196,7 +190,7 class WikiControllerTest < Redmine::ControllerTest
196
190
197 xhr :get, :new, :params => {:project_id => 'ecookbook'}
191 xhr :get, :new, :params => {:project_id => 'ecookbook'}
198 assert_response :success
192 assert_response :success
199 assert_template 'new'
193 assert_include 'Unallowed characters', response.body
200 end
194 end
201
195
202 def test_post_new_with_valid_title_should_redirect_to_edit
196 def test_post_new_with_valid_title_should_redirect_to_edit
@@ -219,7 +213,6 class WikiControllerTest < Redmine::ControllerTest
219
213
220 post :new, :params => {:project_id => 'ecookbook', :title => 'Another page'}
214 post :new, :params => {:project_id => 'ecookbook', :title => 'Another page'}
221 assert_response :success
215 assert_response :success
222 assert_template 'new'
223 assert_select_error 'Title has already been taken'
216 assert_select_error 'Title has already been taken'
224 end
217 end
225
218
@@ -228,7 +221,6 class WikiControllerTest < Redmine::ControllerTest
228
221
229 xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'Another page'}
222 xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'Another page'}
230 assert_response :success
223 assert_response :success
231 assert_template 'new'
232 assert_include 'Title has already been taken', response.body
224 assert_include 'Title has already been taken', response.body
233 end
225 end
234
226
@@ -298,7 +290,6 class WikiControllerTest < Redmine::ControllerTest
298 get :edit, :params => {:project_id => 'ecookbook', :id => 'Another_page'}
290 get :edit, :params => {:project_id => 'ecookbook', :id => 'Another_page'}
299
291
300 assert_response :success
292 assert_response :success
301 assert_template 'edit'
302
293
303 assert_select 'textarea[name=?]', 'content[text]',
294 assert_select 'textarea[name=?]', 'content[text]',
304 :text => WikiPage.find_by_title('Another_page').content.text
295 :text => WikiPage.find_by_title('Another_page').content.text
@@ -309,7 +300,6 class WikiControllerTest < Redmine::ControllerTest
309 get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2}
300 get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2}
310
301
311 assert_response :success
302 assert_response :success
312 assert_template 'edit'
313
303
314 page = WikiPage.find_by_title('Page_with_sections')
304 page = WikiPage.find_by_title('Page_with_sections')
315 section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
305 section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
@@ -398,7 +388,6 class WikiControllerTest < Redmine::ControllerTest
398 end
388 end
399 end
389 end
400 assert_response :success
390 assert_response :success
401 assert_template 'edit'
402
391
403 assert_select_error /Comment is too long/
392 assert_select_error /Comment is too long/
404 assert_select 'textarea#content_text', :text => "edited"
393 assert_select 'textarea#content_text', :text => "edited"
@@ -475,7 +464,6 class WikiControllerTest < Redmine::ControllerTest
475 end
464 end
476 end
465 end
477 assert_response :success
466 assert_response :success
478 assert_template 'edit'
479 assert_select 'div.error', :text => /Data has been updated by another user/
467 assert_select 'div.error', :text => /Data has been updated by another user/
480 assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/
468 assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/
481 assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments'
469 assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments'
@@ -577,7 +565,6 class WikiControllerTest < Redmine::ControllerTest
577 end
565 end
578 end
566 end
579 assert_response :success
567 assert_response :success
580 assert_template 'edit'
581 assert_select 'div.error', :text => /Data has been updated by another user/
568 assert_select 'div.error', :text => /Data has been updated by another user/
582 assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/
569 assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/
583 assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments'
570 assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments'
@@ -595,7 +582,6 class WikiControllerTest < Redmine::ControllerTest
595 }
582 }
596 }
583 }
597 assert_response :success
584 assert_response :success
598 assert_template 'common/_preview'
599 assert_select 'strong', :text => /previewed text/
585 assert_select 'strong', :text => /previewed text/
600 end
586 end
601
587
@@ -611,7 +597,6 class WikiControllerTest < Redmine::ControllerTest
611 }
597 }
612 }
598 }
613 assert_response :success
599 assert_response :success
614 assert_template 'common/_preview'
615 assert_select 'h1', :text => /New page/
600 assert_select 'h1', :text => /New page/
616 end
601 end
617
602
@@ -619,9 +604,10 class WikiControllerTest < Redmine::ControllerTest
619 @request.session[:user_id] = 2
604 @request.session[:user_id] = 2
620 get :history, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation'}
605 get :history, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation'}
621 assert_response :success
606 assert_response :success
622 assert_template 'history'
607
623 assert_not_nil assigns(:versions)
608 assert_select 'table.wiki-page-versions tbody' do
624 assert_equal 3, assigns(:versions).size
609 assert_select 'tr', 3
610 end
625
611
626 assert_select "input[type=submit][name=commit]"
612 assert_select "input[type=submit][name=commit]"
627 assert_select 'td' do
613 assert_select 'td' do
@@ -635,9 +621,11 class WikiControllerTest < Redmine::ControllerTest
635 @request.session[:user_id] = 2
621 @request.session[:user_id] = 2
636 get :history, :params => {:project_id => 'ecookbook', :id => 'Another_page'}
622 get :history, :params => {:project_id => 'ecookbook', :id => 'Another_page'}
637 assert_response :success
623 assert_response :success
638 assert_template 'history'
624
639 assert_not_nil assigns(:versions)
625 assert_select 'table.wiki-page-versions tbody' do
640 assert_equal 1, assigns(:versions).size
626 assert_select 'tr', 1
627 end
628
641 assert_select "input[type=submit][name=commit]", false
629 assert_select "input[type=submit][name=commit]", false
642 assert_select 'td' do
630 assert_select 'td' do
643 assert_select 'a[href=?]', '/projects/ecookbook/wiki/Another_page/1', :text => '1'
631 assert_select 'a[href=?]', '/projects/ecookbook/wiki/Another_page/1', :text => '1'
@@ -661,7 +649,6 class WikiControllerTest < Redmine::ControllerTest
661 :version_from => (content.version - 1)
649 :version_from => (content.version - 1)
662 }
650 }
663 assert_response :success
651 assert_response :success
664 assert_template 'diff'
665 assert_select 'span.diff_out', :text => 'Line removed'
652 assert_select 'span.diff_out', :text => 'Line removed'
666 assert_select 'span.diff_in', :text => 'Line added'
653 assert_select 'span.diff_in', :text => 'Line added'
667 end
654 end
@@ -689,13 +676,19 class WikiControllerTest < Redmine::ControllerTest
689 :version => 2
676 :version => 2
690 }
677 }
691 assert_response :success
678 assert_response :success
692 assert_template 'annotate'
693
679
694 # Line 1
680 # Line 1
695 assert_select 'table.annotate tr:nth-child(1)' do
681 assert_select 'table.annotate tr:nth-child(1)' do
696 assert_select 'th.line-num', :text => '1'
682 assert_select 'th.line-num', :text => '1'
683 assert_select 'td.author', :text => /Redmine Admin/
684 assert_select 'td', :text => /h1\. CookBook documentation v2/
685 end
686
687 # Line 4
688 assert_select 'table.annotate tr:nth-child(4)' do
689 assert_select 'th.line-num', :text => '4'
697 assert_select 'td.author', :text => /John Smith/
690 assert_select 'td.author', :text => /John Smith/
698 assert_select 'td', :text => /h1\. CookBook documentation/
691 assert_select 'td', :text => /Line from v1/
699 end
692 end
700
693
701 # Line 5
694 # Line 5
@@ -718,7 +711,6 class WikiControllerTest < Redmine::ControllerTest
718 @request.session[:user_id] = 2
711 @request.session[:user_id] = 2
719 get :rename, :params => {:project_id => 1, :id => 'Another_page'}
712 get :rename, :params => {:project_id => 1, :id => 'Another_page'}
720 assert_response :success
713 assert_response :success
721 assert_template 'rename'
722
714
723 assert_select 'select[name=?]', 'wiki_page[parent_id]' do
715 assert_select 'select[name=?]', 'wiki_page[parent_id]' do
724 assert_select 'option[value=""]', :text => ''
716 assert_select 'option[value=""]', :text => ''
@@ -730,7 +722,6 class WikiControllerTest < Redmine::ControllerTest
730 @request.session[:user_id] = 2
722 @request.session[:user_id] = 2
731 get :rename, :params => {:project_id => 1, :id => 'Child_1'}
723 get :rename, :params => {:project_id => 1, :id => 'Child_1'}
732 assert_response :success
724 assert_response :success
733 assert_template 'rename'
734
725
735 assert_select 'select[name=?]', 'wiki_page[parent_id]' do
726 assert_select 'select[name=?]', 'wiki_page[parent_id]' do
736 assert_select 'option[value=""]', :text => ''
727 assert_select 'option[value=""]', :text => ''
@@ -808,7 +799,6 class WikiControllerTest < Redmine::ControllerTest
808
799
809 get :rename, :params => {:project_id => 1, :id => 'Another_page'}
800 get :rename, :params => {:project_id => 1, :id => 'Another_page'}
810 assert_response :success
801 assert_response :success
811 assert_template 'rename'
812
802
813 assert_select 'select[name=?]', 'wiki_page[wiki_id]' do
803 assert_select 'select[name=?]', 'wiki_page[wiki_id]' do
814 assert_select 'option', 2
804 assert_select 'option', 2
@@ -849,7 +839,6 class WikiControllerTest < Redmine::ControllerTest
849 delete :destroy, :params => {:project_id => 1, :id => 'Another_page'}
839 delete :destroy, :params => {:project_id => 1, :id => 'Another_page'}
850 end
840 end
851 assert_response :success
841 assert_response :success
852 assert_template 'destroy'
853 assert_select 'form' do
842 assert_select 'form' do
854 assert_select 'input[name=todo][value=nullify]'
843 assert_select 'input[name=todo][value=nullify]'
855 assert_select 'input[name=todo][value=destroy]'
844 assert_select 'input[name=todo][value=destroy]'
@@ -913,11 +902,10 class WikiControllerTest < Redmine::ControllerTest
913 def test_index
902 def test_index
914 get :index, :params => {:project_id => 'ecookbook'}
903 get :index, :params => {:project_id => 'ecookbook'}
915 assert_response :success
904 assert_response :success
916 assert_template 'index'
905
917 pages = assigns(:pages)
906 assert_select 'ul.pages-hierarchy' do
918 assert_not_nil pages
907 assert_select 'li', Project.find(1).wiki.pages.count
919 assert_equal Project.find(1).wiki.pages.size, pages.size
908 end
920 assert_equal pages.first.content.updated_on, pages.first.updated_on
921
909
922 assert_select 'ul.pages-hierarchy' do
910 assert_select 'ul.pages-hierarchy' do
923 assert_select 'li' do
911 assert_select 'li' do
@@ -938,8 +926,6 class WikiControllerTest < Redmine::ControllerTest
938 get :export, :params => {:project_id => 'ecookbook'}
926 get :export, :params => {:project_id => 'ecookbook'}
939
927
940 assert_response :success
928 assert_response :success
941 assert_not_nil assigns(:pages)
942 assert assigns(:pages).any?
943 assert_equal "text/html", @response.content_type
929 assert_equal "text/html", @response.content_type
944
930
945 assert_select "a[name=?]", "CookBook_documentation"
931 assert_select "a[name=?]", "CookBook_documentation"
@@ -952,8 +938,6 class WikiControllerTest < Redmine::ControllerTest
952 get :export, :params => {:project_id => 'ecookbook', :format => 'pdf'}
938 get :export, :params => {:project_id => 'ecookbook', :format => 'pdf'}
953
939
954 assert_response :success
940 assert_response :success
955 assert_not_nil assigns(:pages)
956 assert assigns(:pages).any?
957 assert_equal 'application/pdf', @response.content_type
941 assert_equal 'application/pdf', @response.content_type
958 assert_equal 'attachment; filename="ecookbook.pdf"', @response.headers['Content-Disposition']
942 assert_equal 'attachment; filename="ecookbook.pdf"', @response.headers['Content-Disposition']
959 assert @response.body.starts_with?('%PDF')
943 assert @response.body.starts_with?('%PDF')
@@ -971,9 +955,6 class WikiControllerTest < Redmine::ControllerTest
971 get :date_index, :params => {:project_id => 'ecookbook'}
955 get :date_index, :params => {:project_id => 'ecookbook'}
972
956
973 assert_response :success
957 assert_response :success
974 assert_template 'date_index'
975 assert_not_nil assigns(:pages)
976 assert_not_nil assigns(:pages_by_date)
977
958
978 assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1'
959 assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1'
979 end
960 end
@@ -1005,7 +986,7 class WikiControllerTest < Redmine::ControllerTest
1005 @request.session[:user_id] = 2
986 @request.session[:user_id] = 2
1006 get :show, :params => {:project_id => 1}
987 get :show, :params => {:project_id => 1}
1007 assert_response :success
988 assert_response :success
1008 assert_template 'show'
989
1009 assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit'
990 assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit'
1010 end
991 end
1011
992
@@ -1013,7 +994,7 class WikiControllerTest < Redmine::ControllerTest
1013 @request.session[:user_id] = 4
994 @request.session[:user_id] = 4
1014 get :show, :params => {:project_id => 1}
995 get :show, :params => {:project_id => 1}
1015 assert_response :success
996 assert_response :success
1016 assert_template 'show'
997
1017 assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit', 0
998 assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit', 0
1018 end
999 end
1019
1000
@@ -1021,7 +1002,7 class WikiControllerTest < Redmine::ControllerTest
1021 @request.session[:user_id] = 2
1002 @request.session[:user_id] = 2
1022 get :show, :params => {:project_id => 1, :format => 'pdf'}
1003 get :show, :params => {:project_id => 1, :format => 'pdf'}
1023 assert_response :success
1004 assert_response :success
1024 assert_not_nil assigns(:page)
1005
1025 assert_equal 'application/pdf', @response.content_type
1006 assert_equal 'application/pdf', @response.content_type
1026 assert_equal 'attachment; filename="CookBook_documentation.pdf"',
1007 assert_equal 'attachment; filename="CookBook_documentation.pdf"',
1027 @response.headers['Content-Disposition']
1008 @response.headers['Content-Disposition']
@@ -1031,7 +1012,7 class WikiControllerTest < Redmine::ControllerTest
1031 @request.session[:user_id] = 2
1012 @request.session[:user_id] = 2
1032 get :show, :params => {:project_id => 1, :format => 'html'}
1013 get :show, :params => {:project_id => 1, :format => 'html'}
1033 assert_response :success
1014 assert_response :success
1034 assert_not_nil assigns(:page)
1015
1035 assert_equal 'text/html', @response.content_type
1016 assert_equal 'text/html', @response.content_type
1036 assert_equal 'attachment; filename="CookBook_documentation.html"',
1017 assert_equal 'attachment; filename="CookBook_documentation.html"',
1037 @response.headers['Content-Disposition']
1018 @response.headers['Content-Disposition']
@@ -1042,19 +1023,18 class WikiControllerTest < Redmine::ControllerTest
1042 @request.session[:user_id] = 2
1023 @request.session[:user_id] = 2
1043 get :show, :params => {:project_id => 1, :format => 'html', :version => 2}
1024 get :show, :params => {:project_id => 1, :format => 'html', :version => 2}
1044 assert_response :success
1025 assert_response :success
1045 assert_not_nil assigns(:content)
1026
1046 assert_equal 2, assigns(:content).version
1047 assert_equal 'text/html', @response.content_type
1027 assert_equal 'text/html', @response.content_type
1048 assert_equal 'attachment; filename="CookBook_documentation.html"',
1028 assert_equal 'attachment; filename="CookBook_documentation.html"',
1049 @response.headers['Content-Disposition']
1029 @response.headers['Content-Disposition']
1050 assert_select 'h1', :text => /CookBook documentation/
1030 assert_select 'h1', :text => /CookBook documentation v2/
1051 end
1031 end
1052
1032
1053 def test_show_txt
1033 def test_show_txt
1054 @request.session[:user_id] = 2
1034 @request.session[:user_id] = 2
1055 get :show, :params => {:project_id => 1, :format => 'txt'}
1035 get :show, :params => {:project_id => 1, :format => 'txt'}
1056 assert_response :success
1036 assert_response :success
1057 assert_not_nil assigns(:page)
1037
1058 assert_equal 'text/plain', @response.content_type
1038 assert_equal 'text/plain', @response.content_type
1059 assert_equal 'attachment; filename="CookBook_documentation.txt"',
1039 assert_equal 'attachment; filename="CookBook_documentation.txt"',
1060 @response.headers['Content-Disposition']
1040 @response.headers['Content-Disposition']
@@ -1065,12 +1045,11 class WikiControllerTest < Redmine::ControllerTest
1065 @request.session[:user_id] = 2
1045 @request.session[:user_id] = 2
1066 get :show, :params => {:project_id => 1, :format => 'txt', :version => 2}
1046 get :show, :params => {:project_id => 1, :format => 'txt', :version => 2}
1067 assert_response :success
1047 assert_response :success
1068 assert_not_nil assigns(:content)
1048
1069 assert_equal 2, assigns(:content).version
1070 assert_equal 'text/plain', @response.content_type
1049 assert_equal 'text/plain', @response.content_type
1071 assert_equal 'attachment; filename="CookBook_documentation.txt"',
1050 assert_equal 'attachment; filename="CookBook_documentation.txt"',
1072 @response.headers['Content-Disposition']
1051 @response.headers['Content-Disposition']
1073 assert_include 'h1. CookBook documentation', @response.body
1052 assert_include 'h1. CookBook documentation v2', @response.body
1074 end
1053 end
1075
1054
1076 def test_edit_unprotected_page
1055 def test_edit_unprotected_page
@@ -1078,7 +1057,6 class WikiControllerTest < Redmine::ControllerTest
1078 @request.session[:user_id] = 4
1057 @request.session[:user_id] = 4
1079 get :edit, :params => {:project_id => 1, :id => 'Another_page'}
1058 get :edit, :params => {:project_id => 1, :id => 'Another_page'}
1080 assert_response :success
1059 assert_response :success
1081 assert_template 'edit'
1082 end
1060 end
1083
1061
1084 def test_edit_protected_page_by_nonmember
1062 def test_edit_protected_page_by_nonmember
@@ -1092,7 +1070,6 class WikiControllerTest < Redmine::ControllerTest
1092 @request.session[:user_id] = 2
1070 @request.session[:user_id] = 2
1093 get :edit, :params => {:project_id => 1, :id => 'CookBook_documentation'}
1071 get :edit, :params => {:project_id => 1, :id => 'CookBook_documentation'}
1094 assert_response :success
1072 assert_response :success
1095 assert_template 'edit'
1096 end
1073 end
1097
1074
1098 def test_history_of_non_existing_page_should_return_404
1075 def test_history_of_non_existing_page_should_return_404
@@ -31,7 +31,6 class WikisControllerTest < Redmine::ControllerTest
31 assert_difference 'Wiki.count' do
31 assert_difference 'Wiki.count' do
32 xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => 'Start page' }}
32 xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => 'Start page' }}
33 assert_response :success
33 assert_response :success
34 assert_template 'edit'
35 assert_equal 'text/javascript', response.content_type
34 assert_equal 'text/javascript', response.content_type
36 end
35 end
37
36
@@ -46,7 +45,6 class WikisControllerTest < Redmine::ControllerTest
46 assert_no_difference 'Wiki.count' do
45 assert_no_difference 'Wiki.count' do
47 xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => '' }}
46 xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => '' }}
48 assert_response :success
47 assert_response :success
49 assert_template 'edit'
50 assert_equal 'text/javascript', response.content_type
48 assert_equal 'text/javascript', response.content_type
51 end
49 end
52
50
@@ -60,7 +58,6 class WikisControllerTest < Redmine::ControllerTest
60 assert_no_difference 'Wiki.count' do
58 assert_no_difference 'Wiki.count' do
61 xhr :post, :edit, :params => {:id => 1, :wiki => { :start_page => 'Other start page' }}
59 xhr :post, :edit, :params => {:id => 1, :wiki => { :start_page => 'Other start page' }}
62 assert_response :success
60 assert_response :success
63 assert_template 'edit'
64 assert_equal 'text/javascript', response.content_type
61 assert_equal 'text/javascript', response.content_type
65 end
62 end
66
63
@@ -28,7 +28,6 class WorkflowsControllerTest < Redmine::ControllerTest
28 def test_index
28 def test_index
29 get :index
29 get :index
30 assert_response :success
30 assert_response :success
31 assert_template 'index'
32
31
33 count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count
32 count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count
34 assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s
33 assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s
@@ -37,7 +36,6 class WorkflowsControllerTest < Redmine::ControllerTest
37 def test_get_edit
36 def test_get_edit
38 get :edit
37 get :edit
39 assert_response :success
38 assert_response :success
40 assert_template 'edit'
41 end
39 end
42
40
43 def test_get_edit_with_role_and_tracker
41 def test_get_edit_with_role_and_tracker
@@ -47,12 +45,12 class WorkflowsControllerTest < Redmine::ControllerTest
47
45
48 get :edit, :params => {:role_id => 2, :tracker_id => 1}
46 get :edit, :params => {:role_id => 2, :tracker_id => 1}
49 assert_response :success
47 assert_response :success
50 assert_template 'edit'
51
48
52 # used status only
49 # used status only
53 assert_not_nil assigns(:statuses)
50 statuses = IssueStatus.where(:id => [2, 3, 5]).sorted.pluck(:name)
54 assert_equal [2, 3, 5], assigns(:statuses).collect(&:id)
51 assert_equal ["New issue"] + statuses,
55
52 css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
53
56 # allowed transitions
54 # allowed transitions
57 assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[3][5][always]'
55 assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[3][5][always]'
58 # not allowed
56 # not allowed
@@ -74,8 +72,13 class WorkflowsControllerTest < Redmine::ControllerTest
74 def test_get_edit_with_all_roles_and_all_trackers
72 def test_get_edit_with_all_roles_and_all_trackers
75 get :edit, :params => {:role_id => 'all', :tracker_id => 'all'}
73 get :edit, :params => {:role_id => 'all', :tracker_id => 'all'}
76 assert_response :success
74 assert_response :success
77 assert_equal Role.sorted.to_a, assigns(:roles)
75
78 assert_equal Tracker.sorted.to_a, assigns(:trackers)
76 assert_select 'select[name=?][multiple=multiple]', 'role_id[]' do
77 assert_select 'option[selected=selected]', Role.all.select(&:consider_workflow?).count
78 end
79 assert_select 'select[name=?]', 'tracker_id[]' do
80 assert_select 'option[selected=selected][value=all]'
81 end
79 end
82 end
80
83
81 def test_get_edit_with_role_and_tracker_and_all_statuses
84 def test_get_edit_with_role_and_tracker_and_all_statuses
@@ -83,10 +86,10 class WorkflowsControllerTest < Redmine::ControllerTest
83
86
84 get :edit, :params => {:role_id => 2, :tracker_id => 1, :used_statuses_only => '0'}
87 get :edit, :params => {:role_id => 2, :tracker_id => 1, :used_statuses_only => '0'}
85 assert_response :success
88 assert_response :success
86 assert_template 'edit'
87
89
88 assert_not_nil assigns(:statuses)
90 statuses = IssueStatus.all.sorted.pluck(:name)
89 assert_equal IssueStatus.count, assigns(:statuses).size
91 assert_equal ["New issue"] + statuses,
92 css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
90
93
91 assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]'
94 assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]'
92 end
95 end
@@ -161,7 +164,6 class WorkflowsControllerTest < Redmine::ControllerTest
161 get :permissions
164 get :permissions
162
165
163 assert_response :success
166 assert_response :success
164 assert_template 'permissions'
165 end
167 end
166
168
167 def test_get_permissions_with_role_and_tracker
169 def test_get_permissions_with_role_and_tracker
@@ -172,7 +174,6 class WorkflowsControllerTest < Redmine::ControllerTest
172
174
173 get :permissions, :params => {:role_id => 1, :tracker_id => 2}
175 get :permissions, :params => {:role_id => 1, :tracker_id => 2}
174 assert_response :success
176 assert_response :success
175 assert_template 'permissions'
176
177
177 assert_select 'input[name=?][value="1"]', 'role_id[]'
178 assert_select 'input[name=?][value="1"]', 'role_id[]'
178 assert_select 'input[name=?][value="2"]', 'tracker_id[]'
179 assert_select 'input[name=?][value="2"]', 'tracker_id[]'
@@ -213,7 +214,6 class WorkflowsControllerTest < Redmine::ControllerTest
213
214
214 get :permissions, :params => {:role_id => 1, :tracker_id => 1}
215 get :permissions, :params => {:role_id => 1, :tracker_id => 1}
215 assert_response :success
216 assert_response :success
216 assert_template 'permissions'
217
217
218 # Custom field that is always required
218 # Custom field that is always required
219 # The default option is "(Required)"
219 # The default option is "(Required)"
@@ -231,7 +231,6 class WorkflowsControllerTest < Redmine::ControllerTest
231
231
232 get :permissions, :params => {:role_id => 2, :tracker_id => 1}
232 get :permissions, :params => {:role_id => 2, :tracker_id => 1}
233 assert_response :success
233 assert_response :success
234 assert_template 'permissions'
235
234
236 assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf1.id}]"
235 assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf1.id}]"
237 assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf3.id}]"
236 assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf3.id}]"
@@ -287,7 +286,10 class WorkflowsControllerTest < Redmine::ControllerTest
287
286
288 get :permissions, :params => {:role_id => 1, :tracker_id => 2, :used_statuses_only => '0'}
287 get :permissions, :params => {:role_id => 1, :tracker_id => 2, :used_statuses_only => '0'}
289 assert_response :success
288 assert_response :success
290 assert_equal IssueStatus.sorted.to_a, assigns(:statuses)
289
290 statuses = IssueStatus.all.sorted.pluck(:name)
291 assert_equal statuses,
292 css_select('table.workflows.fields_permissions thead tr:nth-child(2) td:not(:first-child)').map(&:text).map(&:strip)
291 end
293 end
292
294
293 def test_get_permissions_should_set_css_class
295 def test_get_permissions_should_set_css_class
@@ -330,7 +332,7 class WorkflowsControllerTest < Redmine::ControllerTest
330 def test_get_copy
332 def test_get_copy
331 get :copy
333 get :copy
332 assert_response :success
334 assert_response :success
333 assert_template 'copy'
335
334 assert_select 'select[name=source_tracker_id]' do
336 assert_select 'select[name=source_tracker_id]' do
335 assert_select 'option[value="1"]', :text => 'Bug'
337 assert_select 'option[value="1"]', :text => 'Bug'
336 end
338 end
General Comments 0
You need to be logged in to leave comments. Login now