##// END OF EJS Templates
Added tests to cover IssueStatus.destroy and IssueStatus.check_integrity...
Eric Davis -
r1921:cf1ad65cd261
parent child
Show More
@@ -1,56 +1,69
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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.
17
17
18 require File.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19
19
20 class IssueStatusTest < Test::Unit::TestCase
20 class IssueStatusTest < Test::Unit::TestCase
21 fixtures :issue_statuses
21 fixtures :issue_statuses, :issues
22
22
23 def test_create
23 def test_create
24 status = IssueStatus.new :name => "Assigned"
24 status = IssueStatus.new :name => "Assigned"
25 assert !status.save
25 assert !status.save
26 # status name uniqueness
26 # status name uniqueness
27 assert_equal 1, status.errors.count
27 assert_equal 1, status.errors.count
28
28
29 status.name = "Test Status"
29 status.name = "Test Status"
30 assert status.save
30 assert status.save
31 assert !status.is_default
31 assert !status.is_default
32 end
32 end
33
33
34 def test_destroy
35 count_before = IssueStatus.count
36 status = IssueStatus.find(3)
37 assert status.destroy
38 assert_equal count_before - 1, IssueStatus.count
39 end
40
41 def test_destroy_status_in_use
42 # Status assigned to an Issue
43 status = Issue.find(1).status
44 assert_raise(RuntimeError, "Can't delete status") { status.destroy }
45 end
46
34 def test_default
47 def test_default
35 status = IssueStatus.default
48 status = IssueStatus.default
36 assert_kind_of IssueStatus, status
49 assert_kind_of IssueStatus, status
37 end
50 end
38
51
39 def test_change_default
52 def test_change_default
40 status = IssueStatus.find(2)
53 status = IssueStatus.find(2)
41 assert !status.is_default
54 assert !status.is_default
42 status.is_default = true
55 status.is_default = true
43 assert status.save
56 assert status.save
44 status.reload
57 status.reload
45
58
46 assert_equal status, IssueStatus.default
59 assert_equal status, IssueStatus.default
47 assert !IssueStatus.find(1).is_default
60 assert !IssueStatus.find(1).is_default
48 end
61 end
49
62
50 def test_reorder_should_not_clear_default_status
63 def test_reorder_should_not_clear_default_status
51 status = IssueStatus.default
64 status = IssueStatus.default
52 status.move_to_bottom
65 status.move_to_bottom
53 status.reload
66 status.reload
54 assert status.is_default?
67 assert status.is_default?
55 end
68 end
56 end
69 end
General Comments 0
You need to be logged in to leave comments. Login now