summaryrefslogtreecommitdiffstats
path: root/test/unit/issue_relation_test.rb
diff options
context:
space:
mode:
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2011-06-26 12:47:15 +0000
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2011-06-26 12:47:15 +0000
commitf982c5b90d5258196774bccfa6a4c587f2a878c5 (patch)
tree08a6b35b013666df80e564010cb30b003fec166a /test/unit/issue_relation_test.rb
parentee527ab47c3f94dd7853a586b14314b456ffa553 (diff)
downloadredmine-f982c5b90d5258196774bccfa6a4c587f2a878c5.tar.gz
redmine-f982c5b90d5258196774bccfa6a4c587f2a878c5.zip
Fixed circular dependencies possibly introduced when using reverse relations, for instance "blocked by" relations (#8616).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6124 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_relation_test.rb')
-rw-r--r--test/unit/issue_relation_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/unit/issue_relation_test.rb b/test/unit/issue_relation_test.rb
index f0b8fd666..7f1581a26 100644
--- a/test/unit/issue_relation_test.rb
+++ b/test/unit/issue_relation_test.rb
@@ -44,6 +44,9 @@ class IssueRelationTest < ActiveSupport::TestCase
assert_equal from, relation.issue_to
end
+ # TODO : document why it shouldn't be reversed if validation fails : having
+ # relations reversed before the validation would allow simpler code for the
+ # validation
def test_follows_relation_should_not_be_reversed_if_validation_fails
from = Issue.find(1)
to = Issue.find(2)
@@ -82,4 +85,13 @@ class IssueRelationTest < ActiveSupport::TestCase
assert !r.save
assert_not_nil r.errors.on(:base)
end
+
+ def test_validates_circular_dependency_on_reverse_relations
+ IssueRelation.delete_all
+ assert IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(3), :relation_type => IssueRelation::TYPE_BLOCKS)
+ assert IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => IssueRelation::TYPE_BLOCKED)
+ r = IssueRelation.new(:issue_from => Issue.find(2), :issue_to => Issue.find(1), :relation_type => IssueRelation::TYPE_BLOCKED)
+ assert !r.save
+ assert_not_nil r.errors.on(:base)
+ end
end