comparison test/functional/.svn/text-base/projects_controller_test.rb.svn-base @ 37:94944d00e43c

* Update to SVN trunk rev 4411
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Fri, 19 Nov 2010 13:24:41 +0000
parents 40f7cfd4df19
children af80e5618e9b
comparison
equal deleted inserted replaced
22:40f7cfd4df19 37:94944d00e43c
282 get :show, :id => 'ecookbook' 282 get :show, :id => 'ecookbook'
283 assert_response :success 283 assert_response :success
284 assert_template 'show' 284 assert_template 'show'
285 assert_not_nil assigns(:project) 285 assert_not_nil assigns(:project)
286 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) 286 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
287
288 assert_tag 'li', :content => /Development status/
289 end
290
291 def test_show_should_not_display_hidden_custom_fields
292 ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
293 get :show, :id => 'ecookbook'
294 assert_response :success
295 assert_template 'show'
296 assert_not_nil assigns(:project)
297
298 assert_no_tag 'li', :content => /Development status/
287 end 299 end
288 300
289 def test_show_should_not_fail_when_custom_values_are_nil 301 def test_show_should_not_fail_when_custom_values_are_nil
290 project = Project.find_by_identifier('ecookbook') 302 project = Project.find_by_identifier('ecookbook')
291 project.custom_values.first.update_attribute(:value, nil) 303 project.custom_values.first.update_attribute(:value, nil)
292 get :show, :id => 'ecookbook' 304 get :show, :id => 'ecookbook'
293 assert_response :success 305 assert_response :success
294 assert_template 'show' 306 assert_template 'show'
295 assert_not_nil assigns(:project) 307 assert_not_nil assigns(:project)
296 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) 308 assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
309 end
310
311 def show_archived_project_should_be_denied
312 project = Project.find_by_identifier('ecookbook')
313 project.archive!
314
315 get :show, :id => 'ecookbook'
316 assert_response 403
317 assert_nil assigns(:project)
318 assert_tag :tag => 'p', :content => /archived/
297 end 319 end
298 320
299 def test_private_subprojects_hidden 321 def test_private_subprojects_hidden
300 get :show, :id => 'ecookbook' 322 get :show, :id => 'ecookbook'
301 assert_response :success 323 assert_response :success
320 342
321 def test_update 343 def test_update
322 @request.session[:user_id] = 2 # manager 344 @request.session[:user_id] = 2 # manager
323 post :update, :id => 1, :project => {:name => 'Test changed name', 345 post :update, :id => 1, :project => {:name => 'Test changed name',
324 :issue_custom_field_ids => ['']} 346 :issue_custom_field_ids => ['']}
325 assert_redirected_to 'projects/ecookbook/settings' 347 assert_redirected_to '/projects/ecookbook/settings'
326 project = Project.find(1) 348 project = Project.find(1)
327 assert_equal 'Test changed name', project.name 349 assert_equal 'Test changed name', project.name
328 end 350 end
329 351
330 def test_get_destroy 352 def test_get_destroy
336 end 358 end
337 359
338 def test_post_destroy 360 def test_post_destroy
339 @request.session[:user_id] = 1 # admin 361 @request.session[:user_id] = 1 # admin
340 post :destroy, :id => 1, :confirm => 1 362 post :destroy, :id => 1, :confirm => 1
341 assert_redirected_to 'admin/projects' 363 assert_redirected_to '/admin/projects'
342 assert_nil Project.find_by_id(1) 364 assert_nil Project.find_by_id(1)
343 end 365 end
344 366
345 def test_archive 367 def test_archive
346 @request.session[:user_id] = 1 # admin 368 @request.session[:user_id] = 1 # admin
347 post :archive, :id => 1 369 post :archive, :id => 1
348 assert_redirected_to 'admin/projects' 370 assert_redirected_to '/admin/projects'
349 assert !Project.find(1).active? 371 assert !Project.find(1).active?
350 end 372 end
351 373
352 def test_unarchive 374 def test_unarchive
353 @request.session[:user_id] = 1 # admin 375 @request.session[:user_id] = 1 # admin
354 Project.find(1).archive 376 Project.find(1).archive
355 post :unarchive, :id => 1 377 post :unarchive, :id => 1
356 assert_redirected_to 'admin/projects' 378 assert_redirected_to '/admin/projects'
357 assert Project.find(1).active? 379 assert Project.find(1).active?
358 end 380 end
359 381
360 def test_project_breadcrumbs_should_be_limited_to_3_ancestors 382 def test_project_breadcrumbs_should_be_limited_to_3_ancestors
361 CustomField.delete_all 383 CustomField.delete_all
387 get :copy 409 get :copy
388 assert_response :redirect 410 assert_response :redirect
389 assert_redirected_to :controller => 'admin', :action => 'projects' 411 assert_redirected_to :controller => 'admin', :action => 'projects'
390 end 412 end
391 413
414 context "POST :copy" do
415 should "TODO: test the rest of the method"
416
417 should "redirect to the project settings when successful" do
418 @request.session[:user_id] = 1 # admin
419 post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'}
420 assert_response :redirect
421 assert_redirected_to :controller => 'projects', :action => 'settings'
422 end
423 end
424
392 def test_jump_should_redirect_to_active_tab 425 def test_jump_should_redirect_to_active_tab
393 get :show, :id => 1, :jump => 'issues' 426 get :show, :id => 1, :jump => 'issues'
394 assert_redirected_to 'projects/ecookbook/issues' 427 assert_redirected_to '/projects/ecookbook/issues'
395 end 428 end
396 429
397 def test_jump_should_not_redirect_to_inactive_tab 430 def test_jump_should_not_redirect_to_inactive_tab
398 get :show, :id => 3, :jump => 'documents' 431 get :show, :id => 3, :jump => 'documents'
399 assert_response :success 432 assert_response :success