OSDN Git Service

add Redmine trunk rev 3089
[redminele/redminele.git] / redmine / test / unit / issue_status_test.rb
1 # redMine - project management software
2 # Copyright (C) 2006-2007  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.dirname(__FILE__) + '/../test_helper'
19
20 class IssueStatusTest < ActiveSupport::TestCase
21   fixtures :issue_statuses, :issues
22
23   def test_create
24     status = IssueStatus.new :name => "Assigned"
25     assert !status.save
26     # status name uniqueness
27     assert_equal 1, status.errors.count
28     
29     status.name = "Test Status"
30     assert status.save
31     assert !status.is_default
32   end
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
47   def test_default
48     status = IssueStatus.default
49     assert_kind_of IssueStatus, status
50   end
51   
52   def test_change_default
53     status = IssueStatus.find(2)
54     assert !status.is_default
55     status.is_default = true
56     assert status.save
57     status.reload
58     
59     assert_equal status, IssueStatus.default
60     assert !IssueStatus.find(1).is_default
61   end
62   
63   def test_reorder_should_not_clear_default_status
64     status = IssueStatus.default
65     status.move_to_bottom
66     status.reload
67     assert status.is_default?
68   end
69 end