diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-03-17 15:02:57 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-03-17 15:02:57 +0000 |
commit | 38b3e045cf221e8d1aad1ea7fd9e2a86ea0ff5f6 (patch) | |
tree | 374354c3d09066ec44a8bb8881a6bd5afc5e2bb1 /test/unit/issue_test.rb | |
parent | b1afd75620529f855a83bf1202c9dfb630258568 (diff) | |
download | redmine-38b3e045cf221e8d1aad1ea7fd9e2a86ea0ff5f6.tar.gz redmine-38b3e045cf221e8d1aad1ea7fd9e2a86ea0ff5f6.zip |
Fixed: Circular loop when using relations and subtasks (#8794).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11641 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_test.rb')
-rw-r--r-- | test/unit/issue_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 905d5483e..50f9e0437 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -1531,6 +1531,36 @@ class IssueTest < ActiveSupport::TestCase assert child.save end + def test_setting_parent_to_a_dependent_issue_should_not_validate + set_language_if_valid 'en' + issue1 = Issue.generate! + issue2 = Issue.generate! + issue3 = Issue.generate! + IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES) + IssueRelation.create!(:issue_from => issue3, :issue_to => issue1, :relation_type => IssueRelation::TYPE_PRECEDES) + issue3.reload + issue3.parent_issue_id = issue2.id + assert !issue3.valid? + assert_include 'Parent task is invalid', issue3.errors.full_messages + end + + def test_setting_parent_should_not_allow_circular_dependency + set_language_if_valid 'en' + issue1 = Issue.generate! + issue2 = Issue.generate! + IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES) + issue3 = Issue.generate! + issue2.reload + issue2.parent_issue_id = issue3.id + issue2.save! + issue4 = Issue.generate! + IssueRelation.create!(:issue_from => issue3, :issue_to => issue4, :relation_type => IssueRelation::TYPE_PRECEDES) + issue4.reload + issue4.parent_issue_id = issue1.id + assert !issue4.valid? + assert_include 'Parent task is invalid', issue4.errors.full_messages + end + def test_overdue assert Issue.new(:due_date => 1.day.ago.to_date).overdue? assert !Issue.new(:due_date => Date.today).overdue? |