summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2017-12-06 09:01:07 +0000
committerGo MAEDA <maeda@farend.jp>2017-12-06 09:01:07 +0000
commitae842a73db70aecdabf360981f7c36d3b156fc07 (patch)
tree657afc2325c499733082dc9a804341ad8faaf0fd /test
parent0ed07156ad3b106cc73130549a487d54bf5ca64f (diff)
downloadredmine-ae842a73db70aecdabf360981f7c36d3b156fc07.tar.gz
redmine-ae842a73db70aecdabf360981f7c36d3b156fc07.zip
Disallow creating inverse relates issue relations (#27663).
Patch by Gregor Schmidt. git-svn-id: http://svn.redmine.org/redmine/trunk@17056 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/issue_relations_controller_test.rb4
-rw-r--r--test/unit/issue_relation_test.rb14
2 files changed, 16 insertions, 2 deletions
diff --git a/test/functional/issue_relations_controller_test.rb b/test/functional/issue_relations_controller_test.rb
index 020ff32fd..1842786d5 100644
--- a/test/functional/issue_relations_controller_test.rb
+++ b/test/functional/issue_relations_controller_test.rb
@@ -82,8 +82,8 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
assert_equal 'text/javascript', response.content_type
end
relation = IssueRelation.order('id DESC').first
- assert_equal 3, relation.issue_from_id
- assert_equal 1, relation.issue_to_id
+ assert_equal 1, relation.issue_from_id
+ assert_equal 3, relation.issue_to_id
assert_include 'Bug #1', response.body
end
diff --git a/test/unit/issue_relation_test.rb b/test/unit/issue_relation_test.rb
index e6d126dcb..585a8293e 100644
--- a/test/unit/issue_relation_test.rb
+++ b/test/unit/issue_relation_test.rb
@@ -65,6 +65,20 @@ class IssueRelationTest < ActiveSupport::TestCase
assert_equal from, relation.issue_to
end
+ def test_cannot_create_inverse_relates_relations
+ from = Issue.find(1)
+ to = Issue.find(2)
+
+ relation1 = IssueRelation.new :issue_from => from, :issue_to => to,
+ :relation_type => IssueRelation::TYPE_RELATES
+ assert relation1.save
+
+ relation2 = IssueRelation.new :issue_from => to, :issue_to => from,
+ :relation_type => IssueRelation::TYPE_RELATES
+ assert !relation2.save
+ assert_not_equal [], relation2.errors[:base]
+ end
+
def test_follows_relation_should_not_be_reversed_if_validation_fails
from = Issue.find(1)
to = Issue.find(2)