comparison .svn/pristine/97/97df7b6827e22c2665eace13dd5952db27af0ff3.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.expand_path('../../test_helper', __FILE__)
19
20 class IssueStatusesControllerTest < ActionController::TestCase
21 fixtures :issue_statuses, :issues, :users
22
23 def setup
24 User.current = nil
25 @request.session[:user_id] = 1 # admin
26 end
27
28 def test_index
29 get :index
30 assert_response :success
31 assert_template 'index'
32 end
33
34 def test_index_by_anonymous_should_redirect_to_login_form
35 @request.session[:user_id] = nil
36 get :index
37 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fissue_statuses'
38 end
39
40 def test_index_by_user_should_respond_with_406
41 @request.session[:user_id] = 2
42 get :index
43 assert_response 406
44 end
45
46 def test_new
47 get :new
48 assert_response :success
49 assert_template 'new'
50 end
51
52 def test_create
53 assert_difference 'IssueStatus.count' do
54 post :create, :issue_status => {:name => 'New status'}
55 end
56 assert_redirected_to :action => 'index'
57 status = IssueStatus.order('id DESC').first
58 assert_equal 'New status', status.name
59 end
60
61 def test_create_with_failure
62 post :create, :issue_status => {:name => ''}
63 assert_response :success
64 assert_template 'new'
65 assert_error_tag :content => /name can&#x27;t be blank/i
66 end
67
68 def test_edit
69 get :edit, :id => '3'
70 assert_response :success
71 assert_template 'edit'
72 end
73
74 def test_update
75 put :update, :id => '3', :issue_status => {:name => 'Renamed status'}
76 assert_redirected_to :action => 'index'
77 status = IssueStatus.find(3)
78 assert_equal 'Renamed status', status.name
79 end
80
81 def test_update_with_failure
82 put :update, :id => '3', :issue_status => {:name => ''}
83 assert_response :success
84 assert_template 'edit'
85 assert_error_tag :content => /name can&#x27;t be blank/i
86 end
87
88 def test_destroy
89 Issue.delete_all("status_id = 1")
90
91 assert_difference 'IssueStatus.count', -1 do
92 delete :destroy, :id => '1'
93 end
94 assert_redirected_to :action => 'index'
95 assert_nil IssueStatus.find_by_id(1)
96 end
97
98 def test_destroy_should_block_if_status_in_use
99 assert_not_nil Issue.find_by_status_id(1)
100
101 assert_no_difference 'IssueStatus.count' do
102 delete :destroy, :id => '1'
103 end
104 assert_redirected_to :action => 'index'
105 assert_not_nil IssueStatus.find_by_id(1)
106 end
107
108 def test_update_issue_done_ratio_with_issue_done_ratio_set_to_issue_field
109 with_settings :issue_done_ratio => 'issue_field' do
110 post :update_issue_done_ratio
111 assert_match /not updated/, flash[:error].to_s
112 assert_redirected_to '/issue_statuses'
113 end
114 end
115
116 def test_update_issue_done_ratio_with_issue_done_ratio_set_to_issue_status
117 with_settings :issue_done_ratio => 'issue_status' do
118 post :update_issue_done_ratio
119 assert_match /Issue done ratios updated/, flash[:notice].to_s
120 assert_redirected_to '/issue_statuses'
121 end
122 end
123 end