comparison test/functional/issue_statuses_controller_test.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents 8661b858af72
children 433d4f72a19b
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
5 class IssueStatusesController; def rescue_action(e) raise e end; end 5 class IssueStatusesController; def rescue_action(e) raise e end; end
6 6
7 7
8 class IssueStatusesControllerTest < ActionController::TestCase 8 class IssueStatusesControllerTest < ActionController::TestCase
9 fixtures :issue_statuses, :issues 9 fixtures :issue_statuses, :issues
10 10
11 def setup 11 def setup
12 @controller = IssueStatusesController.new 12 @controller = IssueStatusesController.new
13 @request = ActionController::TestRequest.new 13 @request = ActionController::TestRequest.new
14 @response = ActionController::TestResponse.new 14 @response = ActionController::TestResponse.new
15 User.current = nil 15 User.current = nil
16 @request.session[:user_id] = 1 # admin 16 @request.session[:user_id] = 1 # admin
17 end 17 end
18 18
19 def test_index 19 def test_index
20 get :index 20 get :index
21 assert_response :success 21 assert_response :success
22 assert_template 'index' 22 assert_template 'index'
23 end 23 end
24 24
25 def test_index_by_anonymous_should_redirect_to_login_form
26 @request.session[:user_id] = nil
27 get :index
28 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fissue_statuses'
29 end
30
31 def test_index_by_user_should_respond_with_406
32 @request.session[:user_id] = 2
33 get :index
34 assert_response 406
35 end
36
25 def test_new 37 def test_new
26 get :new 38 get :new
27 assert_response :success 39 assert_response :success
28 assert_template 'new' 40 assert_template 'new'
29 end 41 end
30 42
31 def test_create 43 def test_create
32 assert_difference 'IssueStatus.count' do 44 assert_difference 'IssueStatus.count' do
33 post :create, :issue_status => {:name => 'New status'} 45 post :create, :issue_status => {:name => 'New status'}
34 end 46 end
35 assert_redirected_to :action => 'index' 47 assert_redirected_to :action => 'index'
36 status = IssueStatus.find(:first, :order => 'id DESC') 48 status = IssueStatus.find(:first, :order => 'id DESC')
37 assert_equal 'New status', status.name 49 assert_equal 'New status', status.name
38 end 50 end
39 51
40 def test_edit 52 def test_edit
41 get :edit, :id => '3' 53 get :edit, :id => '3'
42 assert_response :success 54 assert_response :success
43 assert_template 'edit' 55 assert_template 'edit'
44 end 56 end
45 57
46 def test_update 58 def test_update
47 post :update, :id => '3', :issue_status => {:name => 'Renamed status'} 59 put :update, :id => '3', :issue_status => {:name => 'Renamed status'}
48 assert_redirected_to :action => 'index' 60 assert_redirected_to :action => 'index'
49 status = IssueStatus.find(3) 61 status = IssueStatus.find(3)
50 assert_equal 'Renamed status', status.name 62 assert_equal 'Renamed status', status.name
51 end 63 end
52 64
53 def test_destroy 65 def test_destroy
54 Issue.delete_all("status_id = 1") 66 Issue.delete_all("status_id = 1")
55 67
56 assert_difference 'IssueStatus.count', -1 do 68 assert_difference 'IssueStatus.count', -1 do
57 post :destroy, :id => '1' 69 delete :destroy, :id => '1'
58 end 70 end
59 assert_redirected_to :action => 'index' 71 assert_redirected_to :action => 'index'
60 assert_nil IssueStatus.find_by_id(1) 72 assert_nil IssueStatus.find_by_id(1)
61 end 73 end
62 74
63 def test_destroy_should_block_if_status_in_use 75 def test_destroy_should_block_if_status_in_use
64 assert_not_nil Issue.find_by_status_id(1) 76 assert_not_nil Issue.find_by_status_id(1)
65 77
66 assert_no_difference 'IssueStatus.count' do 78 assert_no_difference 'IssueStatus.count' do
67 post :destroy, :id => '1' 79 delete :destroy, :id => '1'
68 end 80 end
69 assert_redirected_to :action => 'index' 81 assert_redirected_to :action => 'index'
70 assert_not_nil IssueStatus.find_by_id(1) 82 assert_not_nil IssueStatus.find_by_id(1)
71 end 83 end
72 84
89 101
90 should_set_the_flash_to /Issue done ratios updated/ 102 should_set_the_flash_to /Issue done ratios updated/
91 should_redirect_to('the index') { '/issue_statuses' } 103 should_redirect_to('the index') { '/issue_statuses' }
92 end 104 end
93 end 105 end
94 106
95 end 107 end