Mercurial > hg > soundsoftware-site
comparison test/unit/issue_relation_test.rb @ 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 | 1 # Redmine - project management software |
| 2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 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. |
| 27 :issue_statuses, | 27 :issue_statuses, |
| 28 :issue_relations, | 28 :issue_relations, |
| 29 :enabled_modules, | 29 :enabled_modules, |
| 30 :enumerations, | 30 :enumerations, |
| 31 :trackers | 31 :trackers |
| 32 | |
| 33 include Redmine::I18n | |
| 32 | 34 |
| 33 def test_create | 35 def test_create |
| 34 from = Issue.find(1) | 36 from = Issue.find(1) |
| 35 to = Issue.find(2) | 37 to = Issue.find(2) |
| 36 | 38 |
| 113 ) | 115 ) |
| 114 assert !r.save | 116 assert !r.save |
| 115 assert_not_nil r.errors[:base] | 117 assert_not_nil r.errors[:base] |
| 116 end | 118 end |
| 117 | 119 |
| 120 def test_validates_circular_dependency_of_subtask | |
| 121 set_language_if_valid 'en' | |
| 122 issue1 = Issue.generate! | |
| 123 issue2 = Issue.generate! | |
| 124 IssueRelation.create!( | |
| 125 :issue_from => issue1, :issue_to => issue2, | |
| 126 :relation_type => IssueRelation::TYPE_PRECEDES | |
| 127 ) | |
| 128 child = Issue.generate!(:parent_issue_id => issue2.id) | |
| 129 issue1.reload | |
| 130 child.reload | |
| 131 | |
| 132 r = IssueRelation.new( | |
| 133 :issue_from => child, :issue_to => issue1, | |
| 134 :relation_type => IssueRelation::TYPE_PRECEDES | |
| 135 ) | |
| 136 assert !r.save | |
| 137 assert_include 'This relation would create a circular dependency', r.errors.full_messages | |
| 138 end | |
| 139 | |
| 140 def test_subtasks_should_allow_precedes_relation | |
| 141 parent = Issue.generate! | |
| 142 child1 = Issue.generate!(:parent_issue_id => parent.id) | |
| 143 child2 = Issue.generate!(:parent_issue_id => parent.id) | |
| 144 | |
| 145 r = IssueRelation.new( | |
| 146 :issue_from => child1, :issue_to => child2, | |
| 147 :relation_type => IssueRelation::TYPE_PRECEDES | |
| 148 ) | |
| 149 assert r.valid? | |
| 150 assert r.save | |
| 151 end | |
| 152 | |
| 118 def test_validates_circular_dependency_on_reverse_relations | 153 def test_validates_circular_dependency_on_reverse_relations |
| 119 IssueRelation.delete_all | 154 IssueRelation.delete_all |
| 120 assert IssueRelation.create!( | 155 assert IssueRelation.create!( |
| 121 :issue_from => Issue.find(1), :issue_to => Issue.find(3), | 156 :issue_from => Issue.find(1), :issue_to => Issue.find(3), |
| 122 :relation_type => IssueRelation::TYPE_BLOCKS | 157 :relation_type => IssueRelation::TYPE_BLOCKS |
