Mercurial > hg > soundsoftware-site
comparison test/functional/issue_categories_controller_test.rb @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | 433d4f72a19b |
children | e248c7af89ec |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 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. |
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. |
17 | 17 |
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
19 require 'issue_categories_controller' | |
20 | |
21 # Re-raise errors caught by the controller. | |
22 class IssueCategoriesController; def rescue_action(e) raise e end; end | |
23 | 19 |
24 class IssueCategoriesControllerTest < ActionController::TestCase | 20 class IssueCategoriesControllerTest < ActionController::TestCase |
25 fixtures :projects, :users, :members, :member_roles, :roles, :enabled_modules, :issue_categories, | 21 fixtures :projects, :users, :members, :member_roles, :roles, :enabled_modules, :issue_categories, |
26 :issues | 22 :issues |
27 | 23 |
28 def setup | 24 def setup |
29 @controller = IssueCategoriesController.new | |
30 @request = ActionController::TestRequest.new | |
31 @response = ActionController::TestResponse.new | |
32 User.current = nil | 25 User.current = nil |
33 @request.session[:user_id] = 2 | 26 @request.session[:user_id] = 2 |
34 end | 27 end |
35 | 28 |
36 def test_new | 29 def test_new |
131 assert_template 'destroy' | 124 assert_template 'destroy' |
132 assert_not_nil IssueCategory.find_by_id(1) | 125 assert_not_nil IssueCategory.find_by_id(1) |
133 end | 126 end |
134 | 127 |
135 def test_destroy_category_in_use_with_reassignment | 128 def test_destroy_category_in_use_with_reassignment |
136 issue = Issue.find(:first, :conditions => {:category_id => 1}) | 129 issue = Issue.where(:category_id => 1).first |
137 delete :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2 | 130 delete :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2 |
138 assert_redirected_to '/projects/ecookbook/settings/categories' | 131 assert_redirected_to '/projects/ecookbook/settings/categories' |
139 assert_nil IssueCategory.find_by_id(1) | 132 assert_nil IssueCategory.find_by_id(1) |
140 # check that the issue was reassign | 133 # check that the issue was reassign |
141 assert_equal 2, issue.reload.category_id | 134 assert_equal 2, issue.reload.category_id |
142 end | 135 end |
143 | 136 |
144 def test_destroy_category_in_use_without_reassignment | 137 def test_destroy_category_in_use_without_reassignment |
145 issue = Issue.find(:first, :conditions => {:category_id => 1}) | 138 issue = Issue.where(:category_id => 1).first |
146 delete :destroy, :id => 1, :todo => 'nullify' | 139 delete :destroy, :id => 1, :todo => 'nullify' |
147 assert_redirected_to '/projects/ecookbook/settings/categories' | 140 assert_redirected_to '/projects/ecookbook/settings/categories' |
148 assert_nil IssueCategory.find_by_id(1) | 141 assert_nil IssueCategory.find_by_id(1) |
149 # check that the issue category was nullified | 142 # check that the issue category was nullified |
150 assert_nil issue.reload.category_id | 143 assert_nil issue.reload.category_id |