Mercurial > hg > soundsoftware-site
comparison test/unit/.svn/text-base/issue_status_test.rb.svn-base @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | cca12e1c1fd4 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
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 | |
70 context "#update_done_ratios" do | |
71 setup do | |
72 @issue = Issue.find(1) | |
73 @issue_status = IssueStatus.find(1) | |
74 @issue_status.update_attribute(:default_done_ratio, 50) | |
75 end | |
76 | |
77 context "with Setting.issue_done_ratio using the issue_field" do | |
78 setup do | |
79 Setting.issue_done_ratio = 'issue_field' | |
80 end | |
81 | |
82 should "change nothing" do | |
83 IssueStatus.update_issue_done_ratios | |
84 | |
85 assert_equal 0, Issue.count(:conditions => {:done_ratio => 50}) | |
86 end | |
87 end | |
88 | |
89 context "with Setting.issue_done_ratio using the issue_status" do | |
90 setup do | |
91 Setting.issue_done_ratio = 'issue_status' | |
92 end | |
93 | |
94 should "update all of the issue's done_ratios to match their Issue Status" do | |
95 IssueStatus.update_issue_done_ratios | |
96 | |
97 issues = Issue.find([1,3,4,5,6,7,9,10]) | |
98 issues.each do |issue| | |
99 assert_equal @issue_status, issue.status | |
100 assert_equal 50, issue.read_attribute(:done_ratio) | |
101 end | |
102 end | |
103 end | |
104 end | |
105 end |