##// END OF EJS Templates
remove trailing white-spaces from test/functional/issue_categories_controller_test.rb....
Toshi MARUYAMA -
r6789:2b8d2adee0c5
parent child
Show More
@@ -1,96 +1,96
1 1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19 require 'issue_categories_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class IssueCategoriesController; def rescue_action(e) raise e end; end
23 23
24 24 class IssueCategoriesControllerTest < ActionController::TestCase
25 25 fixtures :projects, :users, :members, :member_roles, :roles, :enabled_modules, :issue_categories
26
26
27 27 def setup
28 28 @controller = IssueCategoriesController.new
29 29 @request = ActionController::TestRequest.new
30 30 @response = ActionController::TestResponse.new
31 31 User.current = nil
32 32 @request.session[:user_id] = 2
33 33 end
34
34
35 35 def test_get_new
36 36 @request.session[:user_id] = 2 # manager
37 37 get :new, :project_id => '1'
38 38 assert_response :success
39 39 assert_template 'new'
40 40 end
41
41
42 42 def test_post_new
43 43 @request.session[:user_id] = 2 # manager
44 44 assert_difference 'IssueCategory.count' do
45 45 post :new, :project_id => '1', :category => {:name => 'New category'}
46 46 end
47 47 assert_redirected_to '/projects/ecookbook/settings/categories'
48 48 category = IssueCategory.find_by_name('New category')
49 49 assert_not_nil category
50 50 assert_equal 1, category.project_id
51 51 end
52
52
53 53 def test_post_edit
54 54 assert_no_difference 'IssueCategory.count' do
55 55 post :edit, :id => 2, :category => { :name => 'Testing' }
56 56 end
57 57 assert_redirected_to '/projects/ecookbook/settings/categories'
58 58 assert_equal 'Testing', IssueCategory.find(2).name
59 59 end
60
60
61 61 def test_edit_not_found
62 62 post :edit, :id => 97, :category => { :name => 'Testing' }
63 63 assert_response 404
64 64 end
65
65
66 66 def test_destroy_category_not_in_use
67 67 post :destroy, :id => 2
68 68 assert_redirected_to '/projects/ecookbook/settings/categories'
69 69 assert_nil IssueCategory.find_by_id(2)
70 70 end
71
71
72 72 def test_destroy_category_in_use
73 73 post :destroy, :id => 1
74 74 assert_response :success
75 75 assert_template 'destroy'
76 76 assert_not_nil IssueCategory.find_by_id(1)
77 77 end
78
78
79 79 def test_destroy_category_in_use_with_reassignment
80 80 issue = Issue.find(:first, :conditions => {:category_id => 1})
81 81 post :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2
82 82 assert_redirected_to '/projects/ecookbook/settings/categories'
83 83 assert_nil IssueCategory.find_by_id(1)
84 84 # check that the issue was reassign
85 85 assert_equal 2, issue.reload.category_id
86 86 end
87
87
88 88 def test_destroy_category_in_use_without_reassignment
89 89 issue = Issue.find(:first, :conditions => {:category_id => 1})
90 90 post :destroy, :id => 1, :todo => 'nullify'
91 91 assert_redirected_to '/projects/ecookbook/settings/categories'
92 92 assert_nil IssueCategory.find_by_id(1)
93 93 # check that the issue category was nullified
94 94 assert_nil issue.reload.category_id
95 95 end
96 96 end
General Comments 0
You need to be logged in to leave comments. Login now