Mercurial > hg > soundsoftware-site
comparison .svn/pristine/ae/aebfff37f858adc52ca91629ed8d12be26a654bf.svn-base @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 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.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class IssueStatusTest < ActiveSupport::TestCase | |
21 fixtures :issue_statuses, :issues, :roles, :trackers | |
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 status = IssueStatus.find(3) | |
36 assert_difference 'IssueStatus.count', -1 do | |
37 assert status.destroy | |
38 end | |
39 assert_nil WorkflowTransition.first(:conditions => {:old_status_id => status.id}) | |
40 assert_nil WorkflowTransition.first(:conditions => {:new_status_id => status.id}) | |
41 end | |
42 | |
43 def test_destroy_status_in_use | |
44 # Status assigned to an Issue | |
45 status = Issue.find(1).status | |
46 assert_raise(RuntimeError, "Can't delete status") { status.destroy } | |
47 end | |
48 | |
49 def test_default | |
50 status = IssueStatus.default | |
51 assert_kind_of IssueStatus, status | |
52 end | |
53 | |
54 def test_change_default | |
55 status = IssueStatus.find(2) | |
56 assert !status.is_default | |
57 status.is_default = true | |
58 assert status.save | |
59 status.reload | |
60 | |
61 assert_equal status, IssueStatus.default | |
62 assert !IssueStatus.find(1).is_default | |
63 end | |
64 | |
65 def test_reorder_should_not_clear_default_status | |
66 status = IssueStatus.default | |
67 status.move_to_bottom | |
68 status.reload | |
69 assert status.is_default? | |
70 end | |
71 | |
72 def test_new_statuses_allowed_to | |
73 WorkflowTransition.delete_all | |
74 | |
75 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false) | |
76 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false) | |
77 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true) | |
78 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :assignee => true) | |
79 status = IssueStatus.find(1) | |
80 role = Role.find(1) | |
81 tracker = Tracker.find(1) | |
82 | |
83 assert_equal [2], status.new_statuses_allowed_to([role], tracker, false, false).map(&:id) | |
84 assert_equal [2], status.find_new_statuses_allowed_to([role], tracker, false, false).map(&:id) | |
85 | |
86 assert_equal [2, 3, 5], status.new_statuses_allowed_to([role], tracker, true, false).map(&:id) | |
87 assert_equal [2, 3, 5], status.find_new_statuses_allowed_to([role], tracker, true, false).map(&:id) | |
88 | |
89 assert_equal [2, 4, 5], status.new_statuses_allowed_to([role], tracker, false, true).map(&:id) | |
90 assert_equal [2, 4, 5], status.find_new_statuses_allowed_to([role], tracker, false, true).map(&:id) | |
91 | |
92 assert_equal [2, 3, 4, 5], status.new_statuses_allowed_to([role], tracker, true, true).map(&:id) | |
93 assert_equal [2, 3, 4, 5], status.find_new_statuses_allowed_to([role], tracker, true, true).map(&:id) | |
94 end | |
95 | |
96 def test_update_done_ratios_with_issue_done_ratio_set_to_issue_field_should_change_nothing | |
97 IssueStatus.find(1).update_attribute(:default_done_ratio, 50) | |
98 | |
99 with_settings :issue_done_ratio => 'issue_field' do | |
100 IssueStatus.update_issue_done_ratios | |
101 assert_equal 0, Issue.count(:conditions => {:done_ratio => 50}) | |
102 end | |
103 end | |
104 | |
105 def test_update_done_ratios_with_issue_done_ratio_set_to_issue_status_should_update_issues | |
106 IssueStatus.find(1).update_attribute(:default_done_ratio, 50) | |
107 | |
108 with_settings :issue_done_ratio => 'issue_status' do | |
109 IssueStatus.update_issue_done_ratios | |
110 issues = Issue.all(:conditions => {:status_id => 1}) | |
111 assert_equal [50], issues.map {|issue| issue.read_attribute(:done_ratio)}.uniq | |
112 end | |
113 end | |
114 | |
115 def test_sorted_scope | |
116 assert_equal IssueStatus.all.sort, IssueStatus.sorted.all | |
117 end | |
118 | |
119 def test_named_scope | |
120 status = IssueStatus.named("resolved").first | |
121 assert_not_nil status | |
122 assert_equal "Resolved", status.name | |
123 end | |
124 end |