@@ -1,16 +1,16 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
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. | |
@@ -23,7 +23,7 class IssueCategoriesController; def rescue_action(e) raise e end; end | |||||
23 |
|
23 | |||
24 | class IssueCategoriesControllerTest < ActionController::TestCase |
|
24 | class IssueCategoriesControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :users, :members, :member_roles, :roles, :enabled_modules, :issue_categories |
|
25 | fixtures :projects, :users, :members, :member_roles, :roles, :enabled_modules, :issue_categories | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = IssueCategoriesController.new |
|
28 | @controller = IssueCategoriesController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
@@ -31,14 +31,14 class IssueCategoriesControllerTest < ActionController::TestCase | |||||
31 | User.current = nil |
|
31 | User.current = nil | |
32 | @request.session[:user_id] = 2 |
|
32 | @request.session[:user_id] = 2 | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def test_get_new |
|
35 | def test_get_new | |
36 | @request.session[:user_id] = 2 # manager |
|
36 | @request.session[:user_id] = 2 # manager | |
37 | get :new, :project_id => '1' |
|
37 | get :new, :project_id => '1' | |
38 | assert_response :success |
|
38 | assert_response :success | |
39 | assert_template 'new' |
|
39 | assert_template 'new' | |
40 | end |
|
40 | end | |
41 |
|
41 | |||
42 | def test_post_new |
|
42 | def test_post_new | |
43 | @request.session[:user_id] = 2 # manager |
|
43 | @request.session[:user_id] = 2 # manager | |
44 | assert_difference 'IssueCategory.count' do |
|
44 | assert_difference 'IssueCategory.count' do | |
@@ -49,7 +49,7 class IssueCategoriesControllerTest < ActionController::TestCase | |||||
49 | assert_not_nil category |
|
49 | assert_not_nil category | |
50 | assert_equal 1, category.project_id |
|
50 | assert_equal 1, category.project_id | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | def test_post_edit |
|
53 | def test_post_edit | |
54 | assert_no_difference 'IssueCategory.count' do |
|
54 | assert_no_difference 'IssueCategory.count' do | |
55 | post :edit, :id => 2, :category => { :name => 'Testing' } |
|
55 | post :edit, :id => 2, :category => { :name => 'Testing' } | |
@@ -57,25 +57,25 class IssueCategoriesControllerTest < ActionController::TestCase | |||||
57 | assert_redirected_to '/projects/ecookbook/settings/categories' |
|
57 | assert_redirected_to '/projects/ecookbook/settings/categories' | |
58 | assert_equal 'Testing', IssueCategory.find(2).name |
|
58 | assert_equal 'Testing', IssueCategory.find(2).name | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | def test_edit_not_found |
|
61 | def test_edit_not_found | |
62 | post :edit, :id => 97, :category => { :name => 'Testing' } |
|
62 | post :edit, :id => 97, :category => { :name => 'Testing' } | |
63 | assert_response 404 |
|
63 | assert_response 404 | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | def test_destroy_category_not_in_use |
|
66 | def test_destroy_category_not_in_use | |
67 | post :destroy, :id => 2 |
|
67 | post :destroy, :id => 2 | |
68 | assert_redirected_to '/projects/ecookbook/settings/categories' |
|
68 | assert_redirected_to '/projects/ecookbook/settings/categories' | |
69 | assert_nil IssueCategory.find_by_id(2) |
|
69 | assert_nil IssueCategory.find_by_id(2) | |
70 | end |
|
70 | end | |
71 |
|
71 | |||
72 | def test_destroy_category_in_use |
|
72 | def test_destroy_category_in_use | |
73 | post :destroy, :id => 1 |
|
73 | post :destroy, :id => 1 | |
74 | assert_response :success |
|
74 | assert_response :success | |
75 | assert_template 'destroy' |
|
75 | assert_template 'destroy' | |
76 | assert_not_nil IssueCategory.find_by_id(1) |
|
76 | assert_not_nil IssueCategory.find_by_id(1) | |
77 | end |
|
77 | end | |
78 |
|
78 | |||
79 | def test_destroy_category_in_use_with_reassignment |
|
79 | def test_destroy_category_in_use_with_reassignment | |
80 | issue = Issue.find(:first, :conditions => {:category_id => 1}) |
|
80 | issue = Issue.find(:first, :conditions => {:category_id => 1}) | |
81 | post :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2 |
|
81 | post :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2 | |
@@ -84,7 +84,7 class IssueCategoriesControllerTest < ActionController::TestCase | |||||
84 | # check that the issue was reassign |
|
84 | # check that the issue was reassign | |
85 | assert_equal 2, issue.reload.category_id |
|
85 | assert_equal 2, issue.reload.category_id | |
86 | end |
|
86 | end | |
87 |
|
87 | |||
88 | def test_destroy_category_in_use_without_reassignment |
|
88 | def test_destroy_category_in_use_without_reassignment | |
89 | issue = Issue.find(:first, :conditions => {:category_id => 1}) |
|
89 | issue = Issue.find(:first, :conditions => {:category_id => 1}) | |
90 | post :destroy, :id => 1, :todo => 'nullify' |
|
90 | post :destroy, :id => 1, :todo => 'nullify' |
General Comments 0
You need to be logged in to leave comments.
Login now