Mercurial > hg > soundsoftware-site
comparison test/unit/issue_status_test.rb @ 1337:077b8890835a cannam
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 20 Jun 2013 13:14:02 +0100 |
parents | 433d4f72a19b |
children | 622f24f53b42 261b3d9a4903 |
comparison
equal
deleted
inserted
replaced
1304:6137548ba453 | 1337:077b8890835a |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 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. |
34 def test_destroy | 34 def test_destroy |
35 status = IssueStatus.find(3) | 35 status = IssueStatus.find(3) |
36 assert_difference 'IssueStatus.count', -1 do | 36 assert_difference 'IssueStatus.count', -1 do |
37 assert status.destroy | 37 assert status.destroy |
38 end | 38 end |
39 assert_nil Workflow.first(:conditions => {:old_status_id => status.id}) | 39 assert_nil WorkflowTransition.first(:conditions => {:old_status_id => status.id}) |
40 assert_nil Workflow.first(:conditions => {:new_status_id => status.id}) | 40 assert_nil WorkflowTransition.first(:conditions => {:new_status_id => status.id}) |
41 end | 41 end |
42 | 42 |
43 def test_destroy_status_in_use | 43 def test_destroy_status_in_use |
44 # Status assigned to an Issue | 44 # Status assigned to an Issue |
45 status = Issue.find(1).status | 45 status = Issue.find(1).status |
68 status.reload | 68 status.reload |
69 assert status.is_default? | 69 assert status.is_default? |
70 end | 70 end |
71 | 71 |
72 def test_new_statuses_allowed_to | 72 def test_new_statuses_allowed_to |
73 Workflow.delete_all | 73 WorkflowTransition.delete_all |
74 | 74 |
75 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false) | 75 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false) |
76 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false) | 76 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false) |
77 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true) | 77 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true) |
78 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :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) | 79 status = IssueStatus.find(1) |
80 role = Role.find(1) | 80 role = Role.find(1) |
81 tracker = Tracker.find(1) | 81 tracker = Tracker.find(1) |
82 | 82 |
83 assert_equal [2], status.new_statuses_allowed_to([role], tracker, false, false).map(&:id) | 83 assert_equal [2], status.new_statuses_allowed_to([role], tracker, false, false).map(&:id) |
91 | 91 |
92 assert_equal [2, 3, 4, 5], status.new_statuses_allowed_to([role], tracker, true, true).map(&:id) | 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) | 93 assert_equal [2, 3, 4, 5], status.find_new_statuses_allowed_to([role], tracker, true, true).map(&:id) |
94 end | 94 end |
95 | 95 |
96 context "#update_done_ratios" do | 96 def test_update_done_ratios_with_issue_done_ratio_set_to_issue_field_should_change_nothing |
97 setup do | 97 IssueStatus.find(1).update_attribute(:default_done_ratio, 50) |
98 @issue = Issue.find(1) | |
99 @issue_status = IssueStatus.find(1) | |
100 @issue_status.update_attribute(:default_done_ratio, 50) | |
101 end | |
102 | 98 |
103 context "with Setting.issue_done_ratio using the issue_field" do | 99 with_settings :issue_done_ratio => 'issue_field' do |
104 setup do | 100 IssueStatus.update_issue_done_ratios |
105 Setting.issue_done_ratio = 'issue_field' | 101 assert_equal 0, Issue.count(:conditions => {:done_ratio => 50}) |
106 end | |
107 | |
108 should "change nothing" do | |
109 IssueStatus.update_issue_done_ratios | |
110 | |
111 assert_equal 0, Issue.count(:conditions => {:done_ratio => 50}) | |
112 end | |
113 end | |
114 | |
115 context "with Setting.issue_done_ratio using the issue_status" do | |
116 setup do | |
117 Setting.issue_done_ratio = 'issue_status' | |
118 end | |
119 | |
120 should "update all of the issue's done_ratios to match their Issue Status" do | |
121 IssueStatus.update_issue_done_ratios | |
122 | |
123 issues = Issue.find([1,3,4,5,6,7,9,10]) | |
124 issues.each do |issue| | |
125 assert_equal @issue_status, issue.status | |
126 assert_equal 50, issue.read_attribute(:done_ratio) | |
127 end | |
128 end | |
129 end | 102 end |
130 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 | |
131 end | 124 end |