##// END OF EJS Templates
remove trailing white-spaces from functional IssuesController test....
Toshi MARUYAMA -
r5677:6a5c9ed3c7cf
parent child
Show More
@@ -5,12 +5,12
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -45,17 +45,17 class IssuesControllerTest < ActionController::TestCase
45 :journals,
45 :journals,
46 :journal_details,
46 :journal_details,
47 :queries
47 :queries
48
48
49 def setup
49 def setup
50 @controller = IssuesController.new
50 @controller = IssuesController.new
51 @request = ActionController::TestRequest.new
51 @request = ActionController::TestRequest.new
52 @response = ActionController::TestResponse.new
52 @response = ActionController::TestResponse.new
53 User.current = nil
53 User.current = nil
54 end
54 end
55
55
56 def test_index
56 def test_index
57 Setting.default_language = 'en'
57 Setting.default_language = 'en'
58
58
59 get :index
59 get :index
60 assert_response :success
60 assert_response :success
61 assert_template 'index.rhtml'
61 assert_template 'index.rhtml'
@@ -69,7 +69,7 class IssuesControllerTest < ActionController::TestCase
69 # project column
69 # project column
70 assert_tag :tag => 'th', :content => /Project/
70 assert_tag :tag => 'th', :content => /Project/
71 end
71 end
72
72
73 def test_index_should_not_list_issues_when_module_disabled
73 def test_index_should_not_list_issues_when_module_disabled
74 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
74 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
75 get :index
75 get :index
@@ -98,7 +98,7 class IssuesControllerTest < ActionController::TestCase
98 assert_not_nil assigns(:issues)
98 assert_not_nil assigns(:issues)
99 assert_nil assigns(:issues).detect {|issue| !issue.visible?}
99 assert_nil assigns(:issues).detect {|issue| !issue.visible?}
100 end
100 end
101
101
102 def test_index_with_project
102 def test_index_with_project
103 Setting.display_subprojects_issues = 0
103 Setting.display_subprojects_issues = 0
104 get :index, :project_id => 1
104 get :index, :project_id => 1
@@ -108,7 +108,7 class IssuesControllerTest < ActionController::TestCase
108 assert_tag :tag => 'a', :content => /Can't print recipes/
108 assert_tag :tag => 'a', :content => /Can't print recipes/
109 assert_no_tag :tag => 'a', :content => /Subproject issue/
109 assert_no_tag :tag => 'a', :content => /Subproject issue/
110 end
110 end
111
111
112 def test_index_with_project_and_subprojects
112 def test_index_with_project_and_subprojects
113 Setting.display_subprojects_issues = 1
113 Setting.display_subprojects_issues = 1
114 get :index, :project_id => 1
114 get :index, :project_id => 1
@@ -119,7 +119,7 class IssuesControllerTest < ActionController::TestCase
119 assert_tag :tag => 'a', :content => /Subproject issue/
119 assert_tag :tag => 'a', :content => /Subproject issue/
120 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
120 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
121 end
121 end
122
122
123 def test_index_with_project_and_subprojects_should_show_private_subprojects
123 def test_index_with_project_and_subprojects_should_show_private_subprojects
124 @request.session[:user_id] = 2
124 @request.session[:user_id] = 2
125 Setting.display_subprojects_issues = 1
125 Setting.display_subprojects_issues = 1
@@ -131,45 +131,45 class IssuesControllerTest < ActionController::TestCase
131 assert_tag :tag => 'a', :content => /Subproject issue/
131 assert_tag :tag => 'a', :content => /Subproject issue/
132 assert_tag :tag => 'a', :content => /Issue of a private subproject/
132 assert_tag :tag => 'a', :content => /Issue of a private subproject/
133 end
133 end
134
134
135 def test_index_with_project_and_default_filter
135 def test_index_with_project_and_default_filter
136 get :index, :project_id => 1, :set_filter => 1
136 get :index, :project_id => 1, :set_filter => 1
137 assert_response :success
137 assert_response :success
138 assert_template 'index.rhtml'
138 assert_template 'index.rhtml'
139 assert_not_nil assigns(:issues)
139 assert_not_nil assigns(:issues)
140
140
141 query = assigns(:query)
141 query = assigns(:query)
142 assert_not_nil query
142 assert_not_nil query
143 # default filter
143 # default filter
144 assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
144 assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
145 end
145 end
146
146
147 def test_index_with_project_and_filter
147 def test_index_with_project_and_filter
148 get :index, :project_id => 1, :set_filter => 1,
148 get :index, :project_id => 1, :set_filter => 1,
149 :f => ['tracker_id'],
149 :f => ['tracker_id'],
150 :op => {'tracker_id' => '='},
150 :op => {'tracker_id' => '='},
151 :v => {'tracker_id' => ['1']}
151 :v => {'tracker_id' => ['1']}
152 assert_response :success
152 assert_response :success
153 assert_template 'index.rhtml'
153 assert_template 'index.rhtml'
154 assert_not_nil assigns(:issues)
154 assert_not_nil assigns(:issues)
155
155
156 query = assigns(:query)
156 query = assigns(:query)
157 assert_not_nil query
157 assert_not_nil query
158 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
158 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
159 end
159 end
160
160
161 def test_index_with_project_and_empty_filters
161 def test_index_with_project_and_empty_filters
162 get :index, :project_id => 1, :set_filter => 1, :fields => ['']
162 get :index, :project_id => 1, :set_filter => 1, :fields => ['']
163 assert_response :success
163 assert_response :success
164 assert_template 'index.rhtml'
164 assert_template 'index.rhtml'
165 assert_not_nil assigns(:issues)
165 assert_not_nil assigns(:issues)
166
166
167 query = assigns(:query)
167 query = assigns(:query)
168 assert_not_nil query
168 assert_not_nil query
169 # no filter
169 # no filter
170 assert_equal({}, query.filters)
170 assert_equal({}, query.filters)
171 end
171 end
172
172
173 def test_index_with_query
173 def test_index_with_query
174 get :index, :project_id => 1, :query_id => 5
174 get :index, :project_id => 1, :query_id => 5
175 assert_response :success
175 assert_response :success
@@ -177,7 +177,7 class IssuesControllerTest < ActionController::TestCase
177 assert_not_nil assigns(:issues)
177 assert_not_nil assigns(:issues)
178 assert_nil assigns(:issue_count_by_group)
178 assert_nil assigns(:issue_count_by_group)
179 end
179 end
180
180
181 def test_index_with_query_grouped_by_tracker
181 def test_index_with_query_grouped_by_tracker
182 get :index, :project_id => 1, :query_id => 6
182 get :index, :project_id => 1, :query_id => 6
183 assert_response :success
183 assert_response :success
@@ -185,7 +185,7 class IssuesControllerTest < ActionController::TestCase
185 assert_not_nil assigns(:issues)
185 assert_not_nil assigns(:issues)
186 assert_not_nil assigns(:issue_count_by_group)
186 assert_not_nil assigns(:issue_count_by_group)
187 end
187 end
188
188
189 def test_index_with_query_grouped_by_list_custom_field
189 def test_index_with_query_grouped_by_list_custom_field
190 get :index, :project_id => 1, :query_id => 9
190 get :index, :project_id => 1, :query_id => 9
191 assert_response :success
191 assert_response :success
@@ -193,15 +193,15 class IssuesControllerTest < ActionController::TestCase
193 assert_not_nil assigns(:issues)
193 assert_not_nil assigns(:issues)
194 assert_not_nil assigns(:issue_count_by_group)
194 assert_not_nil assigns(:issue_count_by_group)
195 end
195 end
196
196
197 def test_index_sort_by_field_not_included_in_columns
197 def test_index_sort_by_field_not_included_in_columns
198 Setting.issue_list_default_columns = %w(subject author)
198 Setting.issue_list_default_columns = %w(subject author)
199 get :index, :sort => 'tracker'
199 get :index, :sort => 'tracker'
200 end
200 end
201
201
202 def test_index_csv_with_project
202 def test_index_csv_with_project
203 Setting.default_language = 'en'
203 Setting.default_language = 'en'
204
204
205 get :index, :format => 'csv'
205 get :index, :format => 'csv'
206 assert_response :success
206 assert_response :success
207 assert_not_nil assigns(:issues)
207 assert_not_nil assigns(:issues)
@@ -213,24 +213,24 class IssuesControllerTest < ActionController::TestCase
213 assert_not_nil assigns(:issues)
213 assert_not_nil assigns(:issues)
214 assert_equal 'text/csv', @response.content_type
214 assert_equal 'text/csv', @response.content_type
215 end
215 end
216
216
217 def test_index_pdf
217 def test_index_pdf
218 get :index, :format => 'pdf'
218 get :index, :format => 'pdf'
219 assert_response :success
219 assert_response :success
220 assert_not_nil assigns(:issues)
220 assert_not_nil assigns(:issues)
221 assert_equal 'application/pdf', @response.content_type
221 assert_equal 'application/pdf', @response.content_type
222
222
223 get :index, :project_id => 1, :format => 'pdf'
223 get :index, :project_id => 1, :format => 'pdf'
224 assert_response :success
224 assert_response :success
225 assert_not_nil assigns(:issues)
225 assert_not_nil assigns(:issues)
226 assert_equal 'application/pdf', @response.content_type
226 assert_equal 'application/pdf', @response.content_type
227
227
228 get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
228 get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
229 assert_response :success
229 assert_response :success
230 assert_not_nil assigns(:issues)
230 assert_not_nil assigns(:issues)
231 assert_equal 'application/pdf', @response.content_type
231 assert_equal 'application/pdf', @response.content_type
232 end
232 end
233
233
234 def test_index_pdf_with_query_grouped_by_list_custom_field
234 def test_index_pdf_with_query_grouped_by_list_custom_field
235 get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
235 get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
236 assert_response :success
236 assert_response :success
@@ -238,47 +238,47 class IssuesControllerTest < ActionController::TestCase
238 assert_not_nil assigns(:issue_count_by_group)
238 assert_not_nil assigns(:issue_count_by_group)
239 assert_equal 'application/pdf', @response.content_type
239 assert_equal 'application/pdf', @response.content_type
240 end
240 end
241
241
242 def test_index_sort
242 def test_index_sort
243 get :index, :sort => 'tracker,id:desc'
243 get :index, :sort => 'tracker,id:desc'
244 assert_response :success
244 assert_response :success
245
245
246 sort_params = @request.session['issues_index_sort']
246 sort_params = @request.session['issues_index_sort']
247 assert sort_params.is_a?(String)
247 assert sort_params.is_a?(String)
248 assert_equal 'tracker,id:desc', sort_params
248 assert_equal 'tracker,id:desc', sort_params
249
249
250 issues = assigns(:issues)
250 issues = assigns(:issues)
251 assert_not_nil issues
251 assert_not_nil issues
252 assert !issues.empty?
252 assert !issues.empty?
253 assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
253 assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
254 end
254 end
255
255
256 def test_index_with_columns
256 def test_index_with_columns
257 columns = ['tracker', 'subject', 'assigned_to']
257 columns = ['tracker', 'subject', 'assigned_to']
258 get :index, :set_filter => 1, :c => columns
258 get :index, :set_filter => 1, :c => columns
259 assert_response :success
259 assert_response :success
260
260
261 # query should use specified columns
261 # query should use specified columns
262 query = assigns(:query)
262 query = assigns(:query)
263 assert_kind_of Query, query
263 assert_kind_of Query, query
264 assert_equal columns, query.column_names.map(&:to_s)
264 assert_equal columns, query.column_names.map(&:to_s)
265
265
266 # columns should be stored in session
266 # columns should be stored in session
267 assert_kind_of Hash, session[:query]
267 assert_kind_of Hash, session[:query]
268 assert_kind_of Array, session[:query][:column_names]
268 assert_kind_of Array, session[:query][:column_names]
269 assert_equal columns, session[:query][:column_names].map(&:to_s)
269 assert_equal columns, session[:query][:column_names].map(&:to_s)
270 end
270 end
271
271
272 def test_index_with_custom_field_column
272 def test_index_with_custom_field_column
273 columns = %w(tracker subject cf_2)
273 columns = %w(tracker subject cf_2)
274 get :index, :set_filter => 1, :c => columns
274 get :index, :set_filter => 1, :c => columns
275 assert_response :success
275 assert_response :success
276
276
277 # query should use specified columns
277 # query should use specified columns
278 query = assigns(:query)
278 query = assigns(:query)
279 assert_kind_of Query, query
279 assert_kind_of Query, query
280 assert_equal columns, query.column_names.map(&:to_s)
280 assert_equal columns, query.column_names.map(&:to_s)
281
281
282 assert_tag :td,
282 assert_tag :td,
283 :attributes => {:class => 'cf_2 string'},
283 :attributes => {:class => 'cf_2 string'},
284 :ancestor => {:tag => 'table', :attributes => {:class => /issues/}}
284 :ancestor => {:tag => 'table', :attributes => {:class => /issues/}}
@@ -290,88 +290,88 class IssuesControllerTest < ActionController::TestCase
290 assert_template 'show.rhtml'
290 assert_template 'show.rhtml'
291 assert_not_nil assigns(:issue)
291 assert_not_nil assigns(:issue)
292 assert_equal Issue.find(1), assigns(:issue)
292 assert_equal Issue.find(1), assigns(:issue)
293
293
294 # anonymous role is allowed to add a note
294 # anonymous role is allowed to add a note
295 assert_tag :tag => 'form',
295 assert_tag :tag => 'form',
296 :descendant => { :tag => 'fieldset',
296 :descendant => { :tag => 'fieldset',
297 :child => { :tag => 'legend',
297 :child => { :tag => 'legend',
298 :content => /Notes/ } }
298 :content => /Notes/ } }
299 end
299 end
300
300
301 def test_show_by_manager
301 def test_show_by_manager
302 @request.session[:user_id] = 2
302 @request.session[:user_id] = 2
303 get :show, :id => 1
303 get :show, :id => 1
304 assert_response :success
304 assert_response :success
305
305
306 assert_tag :tag => 'a',
306 assert_tag :tag => 'a',
307 :content => /Quote/
307 :content => /Quote/
308
308
309 assert_tag :tag => 'form',
309 assert_tag :tag => 'form',
310 :descendant => { :tag => 'fieldset',
310 :descendant => { :tag => 'fieldset',
311 :child => { :tag => 'legend',
311 :child => { :tag => 'legend',
312 :content => /Change properties/ } },
312 :content => /Change properties/ } },
313 :descendant => { :tag => 'fieldset',
313 :descendant => { :tag => 'fieldset',
314 :child => { :tag => 'legend',
314 :child => { :tag => 'legend',
315 :content => /Log time/ } },
315 :content => /Log time/ } },
316 :descendant => { :tag => 'fieldset',
316 :descendant => { :tag => 'fieldset',
317 :child => { :tag => 'legend',
317 :child => { :tag => 'legend',
318 :content => /Notes/ } }
318 :content => /Notes/ } }
319 end
319 end
320
320
321 def test_show_should_deny_anonymous_access_without_permission
321 def test_show_should_deny_anonymous_access_without_permission
322 Role.anonymous.remove_permission!(:view_issues)
322 Role.anonymous.remove_permission!(:view_issues)
323 get :show, :id => 1
323 get :show, :id => 1
324 assert_response :redirect
324 assert_response :redirect
325 end
325 end
326
326
327 def test_show_should_deny_anonymous_access_to_private_issue
327 def test_show_should_deny_anonymous_access_to_private_issue
328 Issue.update_all(["is_private = ?", true], "id = 1")
328 Issue.update_all(["is_private = ?", true], "id = 1")
329 get :show, :id => 1
329 get :show, :id => 1
330 assert_response :redirect
330 assert_response :redirect
331 end
331 end
332
332
333 def test_show_should_deny_non_member_access_without_permission
333 def test_show_should_deny_non_member_access_without_permission
334 Role.non_member.remove_permission!(:view_issues)
334 Role.non_member.remove_permission!(:view_issues)
335 @request.session[:user_id] = 9
335 @request.session[:user_id] = 9
336 get :show, :id => 1
336 get :show, :id => 1
337 assert_response 403
337 assert_response 403
338 end
338 end
339
339
340 def test_show_should_deny_non_member_access_to_private_issue
340 def test_show_should_deny_non_member_access_to_private_issue
341 Issue.update_all(["is_private = ?", true], "id = 1")
341 Issue.update_all(["is_private = ?", true], "id = 1")
342 @request.session[:user_id] = 9
342 @request.session[:user_id] = 9
343 get :show, :id => 1
343 get :show, :id => 1
344 assert_response 403
344 assert_response 403
345 end
345 end
346
346
347 def test_show_should_deny_member_access_without_permission
347 def test_show_should_deny_member_access_without_permission
348 Role.find(1).remove_permission!(:view_issues)
348 Role.find(1).remove_permission!(:view_issues)
349 @request.session[:user_id] = 2
349 @request.session[:user_id] = 2
350 get :show, :id => 1
350 get :show, :id => 1
351 assert_response 403
351 assert_response 403
352 end
352 end
353
353
354 def test_show_should_deny_member_access_to_private_issue_without_permission
354 def test_show_should_deny_member_access_to_private_issue_without_permission
355 Issue.update_all(["is_private = ?", true], "id = 1")
355 Issue.update_all(["is_private = ?", true], "id = 1")
356 @request.session[:user_id] = 3
356 @request.session[:user_id] = 3
357 get :show, :id => 1
357 get :show, :id => 1
358 assert_response 403
358 assert_response 403
359 end
359 end
360
360
361 def test_show_should_allow_author_access_to_private_issue
361 def test_show_should_allow_author_access_to_private_issue
362 Issue.update_all(["is_private = ?, author_id = 3", true], "id = 1")
362 Issue.update_all(["is_private = ?, author_id = 3", true], "id = 1")
363 @request.session[:user_id] = 3
363 @request.session[:user_id] = 3
364 get :show, :id => 1
364 get :show, :id => 1
365 assert_response :success
365 assert_response :success
366 end
366 end
367
367
368 def test_show_should_allow_assignee_access_to_private_issue
368 def test_show_should_allow_assignee_access_to_private_issue
369 Issue.update_all(["is_private = ?, assigned_to_id = 3", true], "id = 1")
369 Issue.update_all(["is_private = ?, assigned_to_id = 3", true], "id = 1")
370 @request.session[:user_id] = 3
370 @request.session[:user_id] = 3
371 get :show, :id => 1
371 get :show, :id => 1
372 assert_response :success
372 assert_response :success
373 end
373 end
374
374
375 def test_show_should_allow_member_access_to_private_issue_with_permission
375 def test_show_should_allow_member_access_to_private_issue_with_permission
376 Issue.update_all(["is_private = ?", true], "id = 1")
376 Issue.update_all(["is_private = ?", true], "id = 1")
377 User.find(3).roles_for_project(Project.find(1)).first.update_attribute :issues_visibility, 'all'
377 User.find(3).roles_for_project(Project.find(1)).first.update_attribute :issues_visibility, 'all'
@@ -379,22 +379,22 class IssuesControllerTest < ActionController::TestCase
379 get :show, :id => 1
379 get :show, :id => 1
380 assert_response :success
380 assert_response :success
381 end
381 end
382
382
383 def test_show_should_not_disclose_relations_to_invisible_issues
383 def test_show_should_not_disclose_relations_to_invisible_issues
384 Setting.cross_project_issue_relations = '1'
384 Setting.cross_project_issue_relations = '1'
385 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
385 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
386 # Relation to a private project issue
386 # Relation to a private project issue
387 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
387 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
388
388
389 get :show, :id => 1
389 get :show, :id => 1
390 assert_response :success
390 assert_response :success
391
391
392 assert_tag :div, :attributes => { :id => 'relations' },
392 assert_tag :div, :attributes => { :id => 'relations' },
393 :descendant => { :tag => 'a', :content => /#2$/ }
393 :descendant => { :tag => 'a', :content => /#2$/ }
394 assert_no_tag :div, :attributes => { :id => 'relations' },
394 assert_no_tag :div, :attributes => { :id => 'relations' },
395 :descendant => { :tag => 'a', :content => /#4$/ }
395 :descendant => { :tag => 'a', :content => /#4$/ }
396 end
396 end
397
397
398 def test_show_atom
398 def test_show_atom
399 get :show, :id => 2, :format => 'atom'
399 get :show, :id => 2, :format => 'atom'
400 assert_response :success
400 assert_response :success
@@ -402,7 +402,7 class IssuesControllerTest < ActionController::TestCase
402 # Inline image
402 # Inline image
403 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
403 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
404 end
404 end
405
405
406 def test_show_export_to_pdf
406 def test_show_export_to_pdf
407 get :show, :id => 3, :format => 'pdf'
407 get :show, :id => 3, :format => 'pdf'
408 assert_response :success
408 assert_response :success
@@ -416,7 +416,7 class IssuesControllerTest < ActionController::TestCase
416 get :new, :project_id => 1, :tracker_id => 1
416 get :new, :project_id => 1, :tracker_id => 1
417 assert_response :success
417 assert_response :success
418 assert_template 'new'
418 assert_template 'new'
419
419
420 assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
420 assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
421 :value => 'Default string' }
421 :value => 'Default string' }
422 end
422 end
@@ -426,51 +426,51 class IssuesControllerTest < ActionController::TestCase
426 get :new, :project_id => 1
426 get :new, :project_id => 1
427 assert_response :success
427 assert_response :success
428 assert_template 'new'
428 assert_template 'new'
429
429
430 issue = assigns(:issue)
430 issue = assigns(:issue)
431 assert_not_nil issue
431 assert_not_nil issue
432 assert_equal Project.find(1).trackers.first, issue.tracker
432 assert_equal Project.find(1).trackers.first, issue.tracker
433 end
433 end
434
434
435 def test_get_new_with_no_default_status_should_display_an_error
435 def test_get_new_with_no_default_status_should_display_an_error
436 @request.session[:user_id] = 2
436 @request.session[:user_id] = 2
437 IssueStatus.delete_all
437 IssueStatus.delete_all
438
438
439 get :new, :project_id => 1
439 get :new, :project_id => 1
440 assert_response 500
440 assert_response 500
441 assert_error_tag :content => /No default issue/
441 assert_error_tag :content => /No default issue/
442 end
442 end
443
443
444 def test_get_new_with_no_tracker_should_display_an_error
444 def test_get_new_with_no_tracker_should_display_an_error
445 @request.session[:user_id] = 2
445 @request.session[:user_id] = 2
446 Tracker.delete_all
446 Tracker.delete_all
447
447
448 get :new, :project_id => 1
448 get :new, :project_id => 1
449 assert_response 500
449 assert_response 500
450 assert_error_tag :content => /No tracker/
450 assert_error_tag :content => /No tracker/
451 end
451 end
452
452
453 def test_update_new_form
453 def test_update_new_form
454 @request.session[:user_id] = 2
454 @request.session[:user_id] = 2
455 xhr :post, :new, :project_id => 1,
455 xhr :post, :new, :project_id => 1,
456 :issue => {:tracker_id => 2,
456 :issue => {:tracker_id => 2,
457 :subject => 'This is the test_new issue',
457 :subject => 'This is the test_new issue',
458 :description => 'This is the description',
458 :description => 'This is the description',
459 :priority_id => 5}
459 :priority_id => 5}
460 assert_response :success
460 assert_response :success
461 assert_template 'attributes'
461 assert_template 'attributes'
462
462
463 issue = assigns(:issue)
463 issue = assigns(:issue)
464 assert_kind_of Issue, issue
464 assert_kind_of Issue, issue
465 assert_equal 1, issue.project_id
465 assert_equal 1, issue.project_id
466 assert_equal 2, issue.tracker_id
466 assert_equal 2, issue.tracker_id
467 assert_equal 'This is the test_new issue', issue.subject
467 assert_equal 'This is the test_new issue', issue.subject
468 end
468 end
469
469
470 def test_post_create
470 def test_post_create
471 @request.session[:user_id] = 2
471 @request.session[:user_id] = 2
472 assert_difference 'Issue.count' do
472 assert_difference 'Issue.count' do
473 post :create, :project_id => 1,
473 post :create, :project_id => 1,
474 :issue => {:tracker_id => 3,
474 :issue => {:tracker_id => 3,
475 :status_id => 2,
475 :status_id => 2,
476 :subject => 'This is the test_new issue',
476 :subject => 'This is the test_new issue',
@@ -481,7 +481,7 class IssuesControllerTest < ActionController::TestCase
481 :custom_field_values => {'2' => 'Value for field 2'}}
481 :custom_field_values => {'2' => 'Value for field 2'}}
482 end
482 end
483 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
483 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
484
484
485 issue = Issue.find_by_subject('This is the test_new issue')
485 issue = Issue.find_by_subject('This is the test_new issue')
486 assert_not_nil issue
486 assert_not_nil issue
487 assert_equal 2, issue.author_id
487 assert_equal 2, issue.author_id
@@ -493,11 +493,11 class IssuesControllerTest < ActionController::TestCase
493 assert_not_nil v
493 assert_not_nil v
494 assert_equal 'Value for field 2', v.value
494 assert_equal 'Value for field 2', v.value
495 end
495 end
496
496
497 def test_post_create_without_start_date
497 def test_post_create_without_start_date
498 @request.session[:user_id] = 2
498 @request.session[:user_id] = 2
499 assert_difference 'Issue.count' do
499 assert_difference 'Issue.count' do
500 post :create, :project_id => 1,
500 post :create, :project_id => 1,
501 :issue => {:tracker_id => 3,
501 :issue => {:tracker_id => 3,
502 :status_id => 2,
502 :status_id => 2,
503 :subject => 'This is the test_new issue',
503 :subject => 'This is the test_new issue',
@@ -508,15 +508,15 class IssuesControllerTest < ActionController::TestCase
508 :custom_field_values => {'2' => 'Value for field 2'}}
508 :custom_field_values => {'2' => 'Value for field 2'}}
509 end
509 end
510 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
510 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
511
511
512 issue = Issue.find_by_subject('This is the test_new issue')
512 issue = Issue.find_by_subject('This is the test_new issue')
513 assert_not_nil issue
513 assert_not_nil issue
514 assert_nil issue.start_date
514 assert_nil issue.start_date
515 end
515 end
516
516
517 def test_post_create_and_continue
517 def test_post_create_and_continue
518 @request.session[:user_id] = 2
518 @request.session[:user_id] = 2
519 post :create, :project_id => 1,
519 post :create, :project_id => 1,
520 :issue => {:tracker_id => 3,
520 :issue => {:tracker_id => 3,
521 :subject => 'This is first issue',
521 :subject => 'This is first issue',
522 :priority_id => 5},
522 :priority_id => 5},
@@ -524,11 +524,11 class IssuesControllerTest < ActionController::TestCase
524 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook',
524 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook',
525 :issue => {:tracker_id => 3}
525 :issue => {:tracker_id => 3}
526 end
526 end
527
527
528 def test_post_create_without_custom_fields_param
528 def test_post_create_without_custom_fields_param
529 @request.session[:user_id] = 2
529 @request.session[:user_id] = 2
530 assert_difference 'Issue.count' do
530 assert_difference 'Issue.count' do
531 post :create, :project_id => 1,
531 post :create, :project_id => 1,
532 :issue => {:tracker_id => 1,
532 :issue => {:tracker_id => 1,
533 :subject => 'This is the test_new issue',
533 :subject => 'This is the test_new issue',
534 :description => 'This is the description',
534 :description => 'This is the description',
@@ -542,7 +542,7 class IssuesControllerTest < ActionController::TestCase
542 field.update_attribute(:is_required, true)
542 field.update_attribute(:is_required, true)
543
543
544 @request.session[:user_id] = 2
544 @request.session[:user_id] = 2
545 post :create, :project_id => 1,
545 post :create, :project_id => 1,
546 :issue => {:tracker_id => 1,
546 :issue => {:tracker_id => 1,
547 :subject => 'This is the test_new issue',
547 :subject => 'This is the test_new issue',
548 :description => 'This is the description',
548 :description => 'This is the description',
@@ -553,13 +553,13 class IssuesControllerTest < ActionController::TestCase
553 assert_not_nil issue
553 assert_not_nil issue
554 assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
554 assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
555 end
555 end
556
556
557 def test_post_create_with_watchers
557 def test_post_create_with_watchers
558 @request.session[:user_id] = 2
558 @request.session[:user_id] = 2
559 ActionMailer::Base.deliveries.clear
559 ActionMailer::Base.deliveries.clear
560
560
561 assert_difference 'Watcher.count', 2 do
561 assert_difference 'Watcher.count', 2 do
562 post :create, :project_id => 1,
562 post :create, :project_id => 1,
563 :issue => {:tracker_id => 1,
563 :issue => {:tracker_id => 1,
564 :subject => 'This is a new issue with watchers',
564 :subject => 'This is a new issue with watchers',
565 :description => 'This is the description',
565 :description => 'This is the description',
@@ -569,7 +569,7 class IssuesControllerTest < ActionController::TestCase
569 issue = Issue.find_by_subject('This is a new issue with watchers')
569 issue = Issue.find_by_subject('This is a new issue with watchers')
570 assert_not_nil issue
570 assert_not_nil issue
571 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
571 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
572
572
573 # Watchers added
573 # Watchers added
574 assert_equal [2, 3], issue.watcher_user_ids.sort
574 assert_equal [2, 3], issue.watcher_user_ids.sort
575 assert issue.watched_by?(User.find(3))
575 assert issue.watched_by?(User.find(3))
@@ -578,12 +578,12 class IssuesControllerTest < ActionController::TestCase
578 assert_kind_of TMail::Mail, mail
578 assert_kind_of TMail::Mail, mail
579 assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
579 assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
580 end
580 end
581
581
582 def test_post_create_subissue
582 def test_post_create_subissue
583 @request.session[:user_id] = 2
583 @request.session[:user_id] = 2
584
584
585 assert_difference 'Issue.count' do
585 assert_difference 'Issue.count' do
586 post :create, :project_id => 1,
586 post :create, :project_id => 1,
587 :issue => {:tracker_id => 1,
587 :issue => {:tracker_id => 1,
588 :subject => 'This is a child issue',
588 :subject => 'This is a child issue',
589 :parent_issue_id => 2}
589 :parent_issue_id => 2}
@@ -595,9 +595,9 class IssuesControllerTest < ActionController::TestCase
595
595
596 def test_post_create_subissue_with_non_numeric_parent_id
596 def test_post_create_subissue_with_non_numeric_parent_id
597 @request.session[:user_id] = 2
597 @request.session[:user_id] = 2
598
598
599 assert_difference 'Issue.count' do
599 assert_difference 'Issue.count' do
600 post :create, :project_id => 1,
600 post :create, :project_id => 1,
601 :issue => {:tracker_id => 1,
601 :issue => {:tracker_id => 1,
602 :subject => 'This is a child issue',
602 :subject => 'This is a child issue',
603 :parent_issue_id => 'ABC'}
603 :parent_issue_id => 'ABC'}
@@ -606,12 +606,12 class IssuesControllerTest < ActionController::TestCase
606 assert_not_nil issue
606 assert_not_nil issue
607 assert_nil issue.parent
607 assert_nil issue.parent
608 end
608 end
609
609
610 def test_post_create_should_send_a_notification
610 def test_post_create_should_send_a_notification
611 ActionMailer::Base.deliveries.clear
611 ActionMailer::Base.deliveries.clear
612 @request.session[:user_id] = 2
612 @request.session[:user_id] = 2
613 assert_difference 'Issue.count' do
613 assert_difference 'Issue.count' do
614 post :create, :project_id => 1,
614 post :create, :project_id => 1,
615 :issue => {:tracker_id => 3,
615 :issue => {:tracker_id => 3,
616 :subject => 'This is the test_new issue',
616 :subject => 'This is the test_new issue',
617 :description => 'This is the description',
617 :description => 'This is the description',
@@ -620,13 +620,13 class IssuesControllerTest < ActionController::TestCase
620 :custom_field_values => {'2' => 'Value for field 2'}}
620 :custom_field_values => {'2' => 'Value for field 2'}}
621 end
621 end
622 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
622 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
623
623
624 assert_equal 1, ActionMailer::Base.deliveries.size
624 assert_equal 1, ActionMailer::Base.deliveries.size
625 end
625 end
626
626
627 def test_post_create_should_preserve_fields_values_on_validation_failure
627 def test_post_create_should_preserve_fields_values_on_validation_failure
628 @request.session[:user_id] = 2
628 @request.session[:user_id] = 2
629 post :create, :project_id => 1,
629 post :create, :project_id => 1,
630 :issue => {:tracker_id => 1,
630 :issue => {:tracker_id => 1,
631 # empty subject
631 # empty subject
632 :subject => '',
632 :subject => '',
@@ -635,35 +635,35 class IssuesControllerTest < ActionController::TestCase
635 :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
635 :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
636 assert_response :success
636 assert_response :success
637 assert_template 'new'
637 assert_template 'new'
638
638
639 assert_tag :textarea, :attributes => { :name => 'issue[description]' },
639 assert_tag :textarea, :attributes => { :name => 'issue[description]' },
640 :content => 'This is a description'
640 :content => 'This is a description'
641 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
641 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
642 :child => { :tag => 'option', :attributes => { :selected => 'selected',
642 :child => { :tag => 'option', :attributes => { :selected => 'selected',
643 :value => '6' },
643 :value => '6' },
644 :content => 'High' }
644 :content => 'High' }
645 # Custom fields
645 # Custom fields
646 assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
646 assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
647 :child => { :tag => 'option', :attributes => { :selected => 'selected',
647 :child => { :tag => 'option', :attributes => { :selected => 'selected',
648 :value => 'Oracle' },
648 :value => 'Oracle' },
649 :content => 'Oracle' }
649 :content => 'Oracle' }
650 assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
650 assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
651 :value => 'Value for field 2'}
651 :value => 'Value for field 2'}
652 end
652 end
653
653
654 def test_post_create_should_ignore_non_safe_attributes
654 def test_post_create_should_ignore_non_safe_attributes
655 @request.session[:user_id] = 2
655 @request.session[:user_id] = 2
656 assert_nothing_raised do
656 assert_nothing_raised do
657 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
657 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
658 end
658 end
659 end
659 end
660
660
661 context "without workflow privilege" do
661 context "without workflow privilege" do
662 setup do
662 setup do
663 Workflow.delete_all(["role_id = ?", Role.anonymous.id])
663 Workflow.delete_all(["role_id = ?", Role.anonymous.id])
664 Role.anonymous.add_permission! :add_issues, :add_issue_notes
664 Role.anonymous.add_permission! :add_issues, :add_issue_notes
665 end
665 end
666
666
667 context "#new" do
667 context "#new" do
668 should "propose default status only" do
668 should "propose default status only" do
669 get :new, :project_id => 1
669 get :new, :project_id => 1
@@ -674,10 +674,10 class IssuesControllerTest < ActionController::TestCase
674 :children => {:count => 1},
674 :children => {:count => 1},
675 :child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
675 :child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
676 end
676 end
677
677
678 should "accept default status" do
678 should "accept default status" do
679 assert_difference 'Issue.count' do
679 assert_difference 'Issue.count' do
680 post :create, :project_id => 1,
680 post :create, :project_id => 1,
681 :issue => {:tracker_id => 1,
681 :issue => {:tracker_id => 1,
682 :subject => 'This is an issue',
682 :subject => 'This is an issue',
683 :status_id => 1}
683 :status_id => 1}
@@ -685,10 +685,10 class IssuesControllerTest < ActionController::TestCase
685 issue = Issue.last(:order => 'id')
685 issue = Issue.last(:order => 'id')
686 assert_equal IssueStatus.default, issue.status
686 assert_equal IssueStatus.default, issue.status
687 end
687 end
688
688
689 should "ignore unauthorized status" do
689 should "ignore unauthorized status" do
690 assert_difference 'Issue.count' do
690 assert_difference 'Issue.count' do
691 post :create, :project_id => 1,
691 post :create, :project_id => 1,
692 :issue => {:tracker_id => 1,
692 :issue => {:tracker_id => 1,
693 :subject => 'This is an issue',
693 :subject => 'This is an issue',
694 :status_id => 3}
694 :status_id => 3}
@@ -697,7 +697,7 class IssuesControllerTest < ActionController::TestCase
697 assert_equal IssueStatus.default, issue.status
697 assert_equal IssueStatus.default, issue.status
698 end
698 end
699 end
699 end
700
700
701 context "#update" do
701 context "#update" do
702 should "ignore status change" do
702 should "ignore status change" do
703 assert_difference 'Journal.count' do
703 assert_difference 'Journal.count' do
@@ -705,7 +705,7 class IssuesControllerTest < ActionController::TestCase
705 end
705 end
706 assert_equal 1, Issue.find(1).status_id
706 assert_equal 1, Issue.find(1).status_id
707 end
707 end
708
708
709 should "ignore attributes changes" do
709 should "ignore attributes changes" do
710 assert_difference 'Journal.count' do
710 assert_difference 'Journal.count' do
711 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
711 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
@@ -716,7 +716,7 class IssuesControllerTest < ActionController::TestCase
716 end
716 end
717 end
717 end
718 end
718 end
719
719
720 context "with workflow privilege" do
720 context "with workflow privilege" do
721 setup do
721 setup do
722 Workflow.delete_all(["role_id = ?", Role.anonymous.id])
722 Workflow.delete_all(["role_id = ?", Role.anonymous.id])
@@ -724,7 +724,7 class IssuesControllerTest < ActionController::TestCase
724 Workflow.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
724 Workflow.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
725 Role.anonymous.add_permission! :add_issues, :add_issue_notes
725 Role.anonymous.add_permission! :add_issues, :add_issue_notes
726 end
726 end
727
727
728 context "#update" do
728 context "#update" do
729 should "accept authorized status" do
729 should "accept authorized status" do
730 assert_difference 'Journal.count' do
730 assert_difference 'Journal.count' do
@@ -732,14 +732,14 class IssuesControllerTest < ActionController::TestCase
732 end
732 end
733 assert_equal 3, Issue.find(1).status_id
733 assert_equal 3, Issue.find(1).status_id
734 end
734 end
735
735
736 should "ignore unauthorized status" do
736 should "ignore unauthorized status" do
737 assert_difference 'Journal.count' do
737 assert_difference 'Journal.count' do
738 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
738 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
739 end
739 end
740 assert_equal 1, Issue.find(1).status_id
740 assert_equal 1, Issue.find(1).status_id
741 end
741 end
742
742
743 should "accept authorized attributes changes" do
743 should "accept authorized attributes changes" do
744 assert_difference 'Journal.count' do
744 assert_difference 'Journal.count' do
745 put :update, :id => 1, :notes => 'just trying', :issue => {:assigned_to_id => 2}
745 put :update, :id => 1, :notes => 'just trying', :issue => {:assigned_to_id => 2}
@@ -747,7 +747,7 class IssuesControllerTest < ActionController::TestCase
747 issue = Issue.find(1)
747 issue = Issue.find(1)
748 assert_equal 2, issue.assigned_to_id
748 assert_equal 2, issue.assigned_to_id
749 end
749 end
750
750
751 should "ignore unauthorized attributes changes" do
751 should "ignore unauthorized attributes changes" do
752 assert_difference 'Journal.count' do
752 assert_difference 'Journal.count' do
753 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed'}
753 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed'}
@@ -756,7 +756,7 class IssuesControllerTest < ActionController::TestCase
756 assert_equal "Can't print recipes", issue.subject
756 assert_equal "Can't print recipes", issue.subject
757 end
757 end
758 end
758 end
759
759
760 context "and :edit_issues permission" do
760 context "and :edit_issues permission" do
761 setup do
761 setup do
762 Role.anonymous.add_permission! :add_issues, :edit_issues
762 Role.anonymous.add_permission! :add_issues, :edit_issues
@@ -768,14 +768,14 class IssuesControllerTest < ActionController::TestCase
768 end
768 end
769 assert_equal 3, Issue.find(1).status_id
769 assert_equal 3, Issue.find(1).status_id
770 end
770 end
771
771
772 should "ignore unauthorized status" do
772 should "ignore unauthorized status" do
773 assert_difference 'Journal.count' do
773 assert_difference 'Journal.count' do
774 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
774 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
775 end
775 end
776 assert_equal 1, Issue.find(1).status_id
776 assert_equal 1, Issue.find(1).status_id
777 end
777 end
778
778
779 should "accept authorized attributes changes" do
779 should "accept authorized attributes changes" do
780 assert_difference 'Journal.count' do
780 assert_difference 'Journal.count' do
781 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
781 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
@@ -786,7 +786,7 class IssuesControllerTest < ActionController::TestCase
786 end
786 end
787 end
787 end
788 end
788 end
789
789
790 def test_copy_issue
790 def test_copy_issue
791 @request.session[:user_id] = 2
791 @request.session[:user_id] = 2
792 get :new, :project_id => 1, :copy_from => 1
792 get :new, :project_id => 1, :copy_from => 1
@@ -795,7 +795,7 class IssuesControllerTest < ActionController::TestCase
795 orig = Issue.find(1)
795 orig = Issue.find(1)
796 assert_equal orig.subject, assigns(:issue).subject
796 assert_equal orig.subject, assigns(:issue).subject
797 end
797 end
798
798
799 def test_get_edit
799 def test_get_edit
800 @request.session[:user_id] = 2
800 @request.session[:user_id] = 2
801 get :edit, :id => 1
801 get :edit, :id => 1
@@ -804,26 +804,26 class IssuesControllerTest < ActionController::TestCase
804 assert_not_nil assigns(:issue)
804 assert_not_nil assigns(:issue)
805 assert_equal Issue.find(1), assigns(:issue)
805 assert_equal Issue.find(1), assigns(:issue)
806 end
806 end
807
807
808 def test_get_edit_with_params
808 def test_get_edit_with_params
809 @request.session[:user_id] = 2
809 @request.session[:user_id] = 2
810 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
810 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
811 :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => TimeEntryActivity.first.id }
811 :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => TimeEntryActivity.first.id }
812 assert_response :success
812 assert_response :success
813 assert_template 'edit'
813 assert_template 'edit'
814
814
815 issue = assigns(:issue)
815 issue = assigns(:issue)
816 assert_not_nil issue
816 assert_not_nil issue
817
817
818 assert_equal 5, issue.status_id
818 assert_equal 5, issue.status_id
819 assert_tag :select, :attributes => { :name => 'issue[status_id]' },
819 assert_tag :select, :attributes => { :name => 'issue[status_id]' },
820 :child => { :tag => 'option',
820 :child => { :tag => 'option',
821 :content => 'Closed',
821 :content => 'Closed',
822 :attributes => { :selected => 'selected' } }
822 :attributes => { :selected => 'selected' } }
823
823
824 assert_equal 7, issue.priority_id
824 assert_equal 7, issue.priority_id
825 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
825 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
826 :child => { :tag => 'option',
826 :child => { :tag => 'option',
827 :content => 'Urgent',
827 :content => 'Urgent',
828 :attributes => { :selected => 'selected' } }
828 :attributes => { :selected => 'selected' } }
829
829
@@ -838,13 +838,13 class IssuesControllerTest < ActionController::TestCase
838 @request.session[:user_id] = 2
838 @request.session[:user_id] = 2
839 xhr :post, :new, :project_id => 1,
839 xhr :post, :new, :project_id => 1,
840 :id => 1,
840 :id => 1,
841 :issue => {:tracker_id => 2,
841 :issue => {:tracker_id => 2,
842 :subject => 'This is the test_new issue',
842 :subject => 'This is the test_new issue',
843 :description => 'This is the description',
843 :description => 'This is the description',
844 :priority_id => 5}
844 :priority_id => 5}
845 assert_response :success
845 assert_response :success
846 assert_template 'attributes'
846 assert_template 'attributes'
847
847
848 issue = assigns(:issue)
848 issue = assigns(:issue)
849 assert_kind_of Issue, issue
849 assert_kind_of Issue, issue
850 assert_equal 1, issue.id
850 assert_equal 1, issue.id
@@ -852,7 +852,7 class IssuesControllerTest < ActionController::TestCase
852 assert_equal 2, issue.tracker_id
852 assert_equal 2, issue.tracker_id
853 assert_equal 'This is the test_new issue', issue.subject
853 assert_equal 'This is the test_new issue', issue.subject
854 end
854 end
855
855
856 def test_update_using_invalid_http_verbs
856 def test_update_using_invalid_http_verbs
857 @request.session[:user_id] = 2
857 @request.session[:user_id] = 2
858 subject = 'Updated by an invalid http verb'
858 subject = 'Updated by an invalid http verb'
@@ -870,12 +870,12 class IssuesControllerTest < ActionController::TestCase
870 def test_put_update_without_custom_fields_param
870 def test_put_update_without_custom_fields_param
871 @request.session[:user_id] = 2
871 @request.session[:user_id] = 2
872 ActionMailer::Base.deliveries.clear
872 ActionMailer::Base.deliveries.clear
873
873
874 issue = Issue.find(1)
874 issue = Issue.find(1)
875 assert_equal '125', issue.custom_value_for(2).value
875 assert_equal '125', issue.custom_value_for(2).value
876 old_subject = issue.subject
876 old_subject = issue.subject
877 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
877 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
878
878
879 assert_difference('Journal.count') do
879 assert_difference('Journal.count') do
880 assert_difference('JournalDetail.count', 2) do
880 assert_difference('JournalDetail.count', 2) do
881 put :update, :id => 1, :issue => {:subject => new_subject,
881 put :update, :id => 1, :issue => {:subject => new_subject,
@@ -889,18 +889,18 class IssuesControllerTest < ActionController::TestCase
889 assert_equal new_subject, issue.subject
889 assert_equal new_subject, issue.subject
890 # Make sure custom fields were not cleared
890 # Make sure custom fields were not cleared
891 assert_equal '125', issue.custom_value_for(2).value
891 assert_equal '125', issue.custom_value_for(2).value
892
892
893 mail = ActionMailer::Base.deliveries.last
893 mail = ActionMailer::Base.deliveries.last
894 assert_kind_of TMail::Mail, mail
894 assert_kind_of TMail::Mail, mail
895 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
895 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
896 assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
896 assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
897 end
897 end
898
898
899 def test_put_update_with_custom_field_change
899 def test_put_update_with_custom_field_change
900 @request.session[:user_id] = 2
900 @request.session[:user_id] = 2
901 issue = Issue.find(1)
901 issue = Issue.find(1)
902 assert_equal '125', issue.custom_value_for(2).value
902 assert_equal '125', issue.custom_value_for(2).value
903
903
904 assert_difference('Journal.count') do
904 assert_difference('Journal.count') do
905 assert_difference('JournalDetail.count', 3) do
905 assert_difference('JournalDetail.count', 3) do
906 put :update, :id => 1, :issue => {:subject => 'Custom field change',
906 put :update, :id => 1, :issue => {:subject => 'Custom field change',
@@ -913,12 +913,12 class IssuesControllerTest < ActionController::TestCase
913 assert_redirected_to :action => 'show', :id => '1'
913 assert_redirected_to :action => 'show', :id => '1'
914 issue.reload
914 issue.reload
915 assert_equal 'New custom value', issue.custom_value_for(2).value
915 assert_equal 'New custom value', issue.custom_value_for(2).value
916
916
917 mail = ActionMailer::Base.deliveries.last
917 mail = ActionMailer::Base.deliveries.last
918 assert_kind_of TMail::Mail, mail
918 assert_kind_of TMail::Mail, mail
919 assert mail.body.include?("Searchable field changed from 125 to New custom value")
919 assert mail.body.include?("Searchable field changed from 125 to New custom value")
920 end
920 end
921
921
922 def test_put_update_with_status_and_assignee_change
922 def test_put_update_with_status_and_assignee_change
923 issue = Issue.find(1)
923 issue = Issue.find(1)
924 assert_equal 1, issue.status_id
924 assert_equal 1, issue.status_id
@@ -936,13 +936,13 class IssuesControllerTest < ActionController::TestCase
936 j = Journal.find(:first, :order => 'id DESC')
936 j = Journal.find(:first, :order => 'id DESC')
937 assert_equal 'Assigned to dlopper', j.notes
937 assert_equal 'Assigned to dlopper', j.notes
938 assert_equal 2, j.details.size
938 assert_equal 2, j.details.size
939
939
940 mail = ActionMailer::Base.deliveries.last
940 mail = ActionMailer::Base.deliveries.last
941 assert mail.body.include?("Status changed from New to Assigned")
941 assert mail.body.include?("Status changed from New to Assigned")
942 # subject should contain the new status
942 # subject should contain the new status
943 assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
943 assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
944 end
944 end
945
945
946 def test_put_update_with_note_only
946 def test_put_update_with_note_only
947 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
947 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
948 # anonymous user
948 # anonymous user
@@ -954,11 +954,11 class IssuesControllerTest < ActionController::TestCase
954 assert_equal notes, j.notes
954 assert_equal notes, j.notes
955 assert_equal 0, j.details.size
955 assert_equal 0, j.details.size
956 assert_equal User.anonymous, j.user
956 assert_equal User.anonymous, j.user
957
957
958 mail = ActionMailer::Base.deliveries.last
958 mail = ActionMailer::Base.deliveries.last
959 assert mail.body.include?(notes)
959 assert mail.body.include?(notes)
960 end
960 end
961
961
962 def test_put_update_with_note_and_spent_time
962 def test_put_update_with_note_and_spent_time
963 @request.session[:user_id] = 2
963 @request.session[:user_id] = 2
964 spent_hours_before = Issue.find(1).spent_hours
964 spent_hours_before = Issue.find(1).spent_hours
@@ -969,22 +969,22 class IssuesControllerTest < ActionController::TestCase
969 :time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
969 :time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
970 end
970 end
971 assert_redirected_to :action => 'show', :id => '1'
971 assert_redirected_to :action => 'show', :id => '1'
972
972
973 issue = Issue.find(1)
973 issue = Issue.find(1)
974
974
975 j = Journal.find(:first, :order => 'id DESC')
975 j = Journal.find(:first, :order => 'id DESC')
976 assert_equal '2.5 hours added', j.notes
976 assert_equal '2.5 hours added', j.notes
977 assert_equal 0, j.details.size
977 assert_equal 0, j.details.size
978
978
979 t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
979 t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
980 assert_not_nil t
980 assert_not_nil t
981 assert_equal 2.5, t.hours
981 assert_equal 2.5, t.hours
982 assert_equal spent_hours_before + 2.5, issue.spent_hours
982 assert_equal spent_hours_before + 2.5, issue.spent_hours
983 end
983 end
984
984
985 def test_put_update_with_attachment_only
985 def test_put_update_with_attachment_only
986 set_tmp_attachments_directory
986 set_tmp_attachments_directory
987
987
988 # Delete all fixtured journals, a race condition can occur causing the wrong
988 # Delete all fixtured journals, a race condition can occur causing the wrong
989 # journal to get fetched in the next find.
989 # journal to get fetched in the next find.
990 Journal.delete_all
990 Journal.delete_all
@@ -1000,21 +1000,21 class IssuesControllerTest < ActionController::TestCase
1000 assert_equal 1, j.details.size
1000 assert_equal 1, j.details.size
1001 assert_equal 'testfile.txt', j.details.first.value
1001 assert_equal 'testfile.txt', j.details.first.value
1002 assert_equal User.anonymous, j.user
1002 assert_equal User.anonymous, j.user
1003
1003
1004 mail = ActionMailer::Base.deliveries.last
1004 mail = ActionMailer::Base.deliveries.last
1005 assert mail.body.include?('testfile.txt')
1005 assert mail.body.include?('testfile.txt')
1006 end
1006 end
1007
1007
1008 def test_put_update_with_attachment_that_fails_to_save
1008 def test_put_update_with_attachment_that_fails_to_save
1009 set_tmp_attachments_directory
1009 set_tmp_attachments_directory
1010
1010
1011 # Delete all fixtured journals, a race condition can occur causing the wrong
1011 # Delete all fixtured journals, a race condition can occur causing the wrong
1012 # journal to get fetched in the next find.
1012 # journal to get fetched in the next find.
1013 Journal.delete_all
1013 Journal.delete_all
1014
1014
1015 # Mock out the unsaved attachment
1015 # Mock out the unsaved attachment
1016 Attachment.any_instance.stubs(:create).returns(Attachment.new)
1016 Attachment.any_instance.stubs(:create).returns(Attachment.new)
1017
1017
1018 # anonymous user
1018 # anonymous user
1019 put :update,
1019 put :update,
1020 :id => 1,
1020 :id => 1,
@@ -1029,12 +1029,12 class IssuesControllerTest < ActionController::TestCase
1029 issue = Issue.find(1)
1029 issue = Issue.find(1)
1030 issue.journals.clear
1030 issue.journals.clear
1031 ActionMailer::Base.deliveries.clear
1031 ActionMailer::Base.deliveries.clear
1032
1032
1033 put :update,
1033 put :update,
1034 :id => 1,
1034 :id => 1,
1035 :notes => ''
1035 :notes => ''
1036 assert_redirected_to :action => 'show', :id => '1'
1036 assert_redirected_to :action => 'show', :id => '1'
1037
1037
1038 issue.reload
1038 issue.reload
1039 assert issue.journals.empty?
1039 assert issue.journals.empty?
1040 # No email should be sent
1040 # No email should be sent
@@ -1047,18 +1047,18 class IssuesControllerTest < ActionController::TestCase
1047 issue = Issue.find(1)
1047 issue = Issue.find(1)
1048 old_subject = issue.subject
1048 old_subject = issue.subject
1049 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
1049 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
1050
1050
1051 put :update, :id => 1, :issue => {:subject => new_subject,
1051 put :update, :id => 1, :issue => {:subject => new_subject,
1052 :priority_id => '6',
1052 :priority_id => '6',
1053 :category_id => '1' # no change
1053 :category_id => '1' # no change
1054 }
1054 }
1055 assert_equal 1, ActionMailer::Base.deliveries.size
1055 assert_equal 1, ActionMailer::Base.deliveries.size
1056 end
1056 end
1057
1057
1058 def test_put_update_with_invalid_spent_time_hours_only
1058 def test_put_update_with_invalid_spent_time_hours_only
1059 @request.session[:user_id] = 2
1059 @request.session[:user_id] = 2
1060 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
1060 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
1061
1061
1062 assert_no_difference('Journal.count') do
1062 assert_no_difference('Journal.count') do
1063 put :update,
1063 put :update,
1064 :id => 1,
1064 :id => 1,
@@ -1067,16 +1067,16 class IssuesControllerTest < ActionController::TestCase
1067 end
1067 end
1068 assert_response :success
1068 assert_response :success
1069 assert_template 'edit'
1069 assert_template 'edit'
1070
1070
1071 assert_error_tag :descendant => {:content => /Activity can't be blank/}
1071 assert_error_tag :descendant => {:content => /Activity can't be blank/}
1072 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => notes
1072 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => notes
1073 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
1073 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
1074 end
1074 end
1075
1075
1076 def test_put_update_with_invalid_spent_time_comments_only
1076 def test_put_update_with_invalid_spent_time_comments_only
1077 @request.session[:user_id] = 2
1077 @request.session[:user_id] = 2
1078 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
1078 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
1079
1079
1080 assert_no_difference('Journal.count') do
1080 assert_no_difference('Journal.count') do
1081 put :update,
1081 put :update,
1082 :id => 1,
1082 :id => 1,
@@ -1085,13 +1085,13 class IssuesControllerTest < ActionController::TestCase
1085 end
1085 end
1086 assert_response :success
1086 assert_response :success
1087 assert_template 'edit'
1087 assert_template 'edit'
1088
1088
1089 assert_error_tag :descendant => {:content => /Activity can't be blank/}
1089 assert_error_tag :descendant => {:content => /Activity can't be blank/}
1090 assert_error_tag :descendant => {:content => /Hours can't be blank/}
1090 assert_error_tag :descendant => {:content => /Hours can't be blank/}
1091 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => notes
1091 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => notes
1092 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => "this is my comment" }
1092 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => "this is my comment" }
1093 end
1093 end
1094
1094
1095 def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
1095 def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
1096 issue = Issue.find(2)
1096 issue = Issue.find(2)
1097 @request.session[:user_id] = 2
1097 @request.session[:user_id] = 2
@@ -1122,7 +1122,7 class IssuesControllerTest < ActionController::TestCase
1122 assert_response :redirect
1122 assert_response :redirect
1123 assert_redirected_to '/issues'
1123 assert_redirected_to '/issues'
1124 end
1124 end
1125
1125
1126 def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
1126 def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
1127 issue = Issue.find(2)
1127 issue = Issue.find(2)
1128 @request.session[:user_id] = 2
1128 @request.session[:user_id] = 2
@@ -1137,21 +1137,21 class IssuesControllerTest < ActionController::TestCase
1137 assert_response :redirect
1137 assert_response :redirect
1138 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
1138 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
1139 end
1139 end
1140
1140
1141 def test_get_bulk_edit
1141 def test_get_bulk_edit
1142 @request.session[:user_id] = 2
1142 @request.session[:user_id] = 2
1143 get :bulk_edit, :ids => [1, 2]
1143 get :bulk_edit, :ids => [1, 2]
1144 assert_response :success
1144 assert_response :success
1145 assert_template 'bulk_edit'
1145 assert_template 'bulk_edit'
1146
1146
1147 assert_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
1147 assert_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
1148
1148
1149 # Project specific custom field, date type
1149 # Project specific custom field, date type
1150 field = CustomField.find(9)
1150 field = CustomField.find(9)
1151 assert !field.is_for_all?
1151 assert !field.is_for_all?
1152 assert_equal 'date', field.field_format
1152 assert_equal 'date', field.field_format
1153 assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
1153 assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
1154
1154
1155 # System wide custom field
1155 # System wide custom field
1156 assert CustomField.find(1).is_for_all?
1156 assert CustomField.find(1).is_for_all?
1157 assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
1157 assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
@@ -1162,25 +1162,25 class IssuesControllerTest < ActionController::TestCase
1162 get :bulk_edit, :ids => [1, 2, 6]
1162 get :bulk_edit, :ids => [1, 2, 6]
1163 assert_response :success
1163 assert_response :success
1164 assert_template 'bulk_edit'
1164 assert_template 'bulk_edit'
1165
1165
1166 # Can not set issues from different projects as children of an issue
1166 # Can not set issues from different projects as children of an issue
1167 assert_no_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
1167 assert_no_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
1168
1168
1169 # Project specific custom field, date type
1169 # Project specific custom field, date type
1170 field = CustomField.find(9)
1170 field = CustomField.find(9)
1171 assert !field.is_for_all?
1171 assert !field.is_for_all?
1172 assert !field.project_ids.include?(Issue.find(6).project_id)
1172 assert !field.project_ids.include?(Issue.find(6).project_id)
1173 assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
1173 assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
1174 end
1174 end
1175
1175
1176 def test_get_bulk_edit_with_user_custom_field
1176 def test_get_bulk_edit_with_user_custom_field
1177 field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true)
1177 field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true)
1178
1178
1179 @request.session[:user_id] = 2
1179 @request.session[:user_id] = 2
1180 get :bulk_edit, :ids => [1, 2]
1180 get :bulk_edit, :ids => [1, 2]
1181 assert_response :success
1181 assert_response :success
1182 assert_template 'bulk_edit'
1182 assert_template 'bulk_edit'
1183
1183
1184 assert_tag :select,
1184 assert_tag :select,
1185 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
1185 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
1186 :children => {
1186 :children => {
@@ -1188,15 +1188,15 class IssuesControllerTest < ActionController::TestCase
1188 :count => Project.find(1).users.count + 1
1188 :count => Project.find(1).users.count + 1
1189 }
1189 }
1190 end
1190 end
1191
1191
1192 def test_get_bulk_edit_with_version_custom_field
1192 def test_get_bulk_edit_with_version_custom_field
1193 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true)
1193 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true)
1194
1194
1195 @request.session[:user_id] = 2
1195 @request.session[:user_id] = 2
1196 get :bulk_edit, :ids => [1, 2]
1196 get :bulk_edit, :ids => [1, 2]
1197 assert_response :success
1197 assert_response :success
1198 assert_template 'bulk_edit'
1198 assert_template 'bulk_edit'
1199
1199
1200 assert_tag :select,
1200 assert_tag :select,
1201 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
1201 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
1202 :children => {
1202 :children => {
@@ -1212,11 +1212,11 class IssuesControllerTest < ActionController::TestCase
1212 :issue => {:priority_id => 7,
1212 :issue => {:priority_id => 7,
1213 :assigned_to_id => '',
1213 :assigned_to_id => '',
1214 :custom_field_values => {'2' => ''}}
1214 :custom_field_values => {'2' => ''}}
1215
1215
1216 assert_response 302
1216 assert_response 302
1217 # check that the issues were updated
1217 # check that the issues were updated
1218 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
1218 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
1219
1219
1220 issue = Issue.find(1)
1220 issue = Issue.find(1)
1221 journal = issue.journals.find(:first, :order => 'created_on DESC')
1221 journal = issue.journals.find(:first, :order => 'created_on DESC')
1222 assert_equal '125', issue.custom_value_for(2).value
1222 assert_equal '125', issue.custom_value_for(2).value
@@ -1231,11 +1231,11 class IssuesControllerTest < ActionController::TestCase
1231 :issue => {:priority_id => 7,
1231 :issue => {:priority_id => 7,
1232 :assigned_to_id => '',
1232 :assigned_to_id => '',
1233 :custom_field_values => {'2' => ''}}
1233 :custom_field_values => {'2' => ''}}
1234
1234
1235 assert_response 302
1235 assert_response 302
1236 # check that the issues were updated
1236 # check that the issues were updated
1237 assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id)
1237 assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id)
1238
1238
1239 issue = Issue.find(1)
1239 issue = Issue.find(1)
1240 journal = issue.journals.find(:first, :order => 'created_on DESC')
1240 journal = issue.journals.find(:first, :order => 'created_on DESC')
1241 assert_equal '125', issue.custom_value_for(2).value
1241 assert_equal '125', issue.custom_value_for(2).value
@@ -1256,7 +1256,7 class IssuesControllerTest < ActionController::TestCase
1256 assert_response 403
1256 assert_response 403
1257 assert_not_equal "Bulk should fail", Journal.last.notes
1257 assert_not_equal "Bulk should fail", Journal.last.notes
1258 end
1258 end
1259
1259
1260 def test_bullk_update_should_send_a_notification
1260 def test_bullk_update_should_send_a_notification
1261 @request.session[:user_id] = 2
1261 @request.session[:user_id] = 2
1262 ActionMailer::Base.deliveries.clear
1262 ActionMailer::Base.deliveries.clear
@@ -1282,18 +1282,18 class IssuesControllerTest < ActionController::TestCase
1282 :issue => {:priority_id => '',
1282 :issue => {:priority_id => '',
1283 :assigned_to_id => '',
1283 :assigned_to_id => '',
1284 :status_id => '5'}
1284 :status_id => '5'}
1285
1285
1286 assert_response 302
1286 assert_response 302
1287 issue = Issue.find(1)
1287 issue = Issue.find(1)
1288 assert issue.closed?
1288 assert issue.closed?
1289 end
1289 end
1290
1290
1291 def test_bulk_update_parent_id
1291 def test_bulk_update_parent_id
1292 @request.session[:user_id] = 2
1292 @request.session[:user_id] = 2
1293 post :bulk_update, :ids => [1, 3],
1293 post :bulk_update, :ids => [1, 3],
1294 :notes => 'Bulk editing parent',
1294 :notes => 'Bulk editing parent',
1295 :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_issue_id => '2'}
1295 :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_issue_id => '2'}
1296
1296
1297 assert_response 302
1297 assert_response 302
1298 parent = Issue.find(2)
1298 parent = Issue.find(2)
1299 assert_equal parent.id, Issue.find(1).parent_id
1299 assert_equal parent.id, Issue.find(1).parent_id
@@ -1308,9 +1308,9 class IssuesControllerTest < ActionController::TestCase
1308 :issue => {:priority_id => '',
1308 :issue => {:priority_id => '',
1309 :assigned_to_id => '',
1309 :assigned_to_id => '',
1310 :custom_field_values => {'2' => '777'}}
1310 :custom_field_values => {'2' => '777'}}
1311
1311
1312 assert_response 302
1312 assert_response 302
1313
1313
1314 issue = Issue.find(1)
1314 issue = Issue.find(1)
1315 journal = issue.journals.find(:first, :order => 'created_on DESC')
1315 journal = issue.journals.find(:first, :order => 'created_on DESC')
1316 assert_equal '777', issue.custom_value_for(2).value
1316 assert_equal '777', issue.custom_value_for(2).value
@@ -1328,7 +1328,7 class IssuesControllerTest < ActionController::TestCase
1328 # check that the issues were updated
1328 # check that the issues were updated
1329 assert_nil Issue.find(2).assigned_to
1329 assert_nil Issue.find(2).assigned_to
1330 end
1330 end
1331
1331
1332 def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject
1332 def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject
1333 @request.session[:user_id] = 2
1333 @request.session[:user_id] = 2
1334
1334
@@ -1357,7 +1357,7 class IssuesControllerTest < ActionController::TestCase
1357 assert_response :redirect
1357 assert_response :redirect
1358 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
1358 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
1359 end
1359 end
1360
1360
1361 def test_destroy_issue_with_no_time_entries
1361 def test_destroy_issue_with_no_time_entries
1362 assert_nil TimeEntry.find_by_issue_id(2)
1362 assert_nil TimeEntry.find_by_issue_id(2)
1363 @request.session[:user_id] = 2
1363 @request.session[:user_id] = 2
@@ -1391,7 +1391,7 class IssuesControllerTest < ActionController::TestCase
1391 assert_nil TimeEntry.find(1).issue_id
1391 assert_nil TimeEntry.find(1).issue_id
1392 assert_nil TimeEntry.find(2).issue_id
1392 assert_nil TimeEntry.find(2).issue_id
1393 end
1393 end
1394
1394
1395 def test_destroy_issues_and_reassign_time_entries_to_another_issue
1395 def test_destroy_issues_and_reassign_time_entries_to_another_issue
1396 @request.session[:user_id] = 2
1396 @request.session[:user_id] = 2
1397 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
1397 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
@@ -1400,26 +1400,26 class IssuesControllerTest < ActionController::TestCase
1400 assert_equal 2, TimeEntry.find(1).issue_id
1400 assert_equal 2, TimeEntry.find(1).issue_id
1401 assert_equal 2, TimeEntry.find(2).issue_id
1401 assert_equal 2, TimeEntry.find(2).issue_id
1402 end
1402 end
1403
1403
1404 def test_destroy_issues_from_different_projects
1404 def test_destroy_issues_from_different_projects
1405 @request.session[:user_id] = 2
1405 @request.session[:user_id] = 2
1406 post :destroy, :ids => [1, 2, 6], :todo => 'destroy'
1406 post :destroy, :ids => [1, 2, 6], :todo => 'destroy'
1407 assert_redirected_to :controller => 'issues', :action => 'index'
1407 assert_redirected_to :controller => 'issues', :action => 'index'
1408 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
1408 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
1409 end
1409 end
1410
1410
1411 def test_destroy_parent_and_child_issues
1411 def test_destroy_parent_and_child_issues
1412 parent = Issue.generate!(:project_id => 1, :tracker_id => 1)
1412 parent = Issue.generate!(:project_id => 1, :tracker_id => 1)
1413 child = Issue.generate!(:project_id => 1, :tracker_id => 1, :parent_issue_id => parent.id)
1413 child = Issue.generate!(:project_id => 1, :tracker_id => 1, :parent_issue_id => parent.id)
1414 assert child.is_descendant_of?(parent.reload)
1414 assert child.is_descendant_of?(parent.reload)
1415
1415
1416 @request.session[:user_id] = 2
1416 @request.session[:user_id] = 2
1417 assert_difference 'Issue.count', -2 do
1417 assert_difference 'Issue.count', -2 do
1418 post :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
1418 post :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
1419 end
1419 end
1420 assert_response 302
1420 assert_response 302
1421 end
1421 end
1422
1422
1423 def test_default_search_scope
1423 def test_default_search_scope
1424 get :index
1424 get :index
1425 assert_tag :div, :attributes => {:id => 'quick-search'},
1425 assert_tag :div, :attributes => {:id => 'quick-search'},
General Comments 0
You need to be logged in to leave comments. Login now