diff options
author | Go MAEDA <maeda@farend.jp> | 2017-12-06 13:24:49 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2017-12-06 13:24:49 +0000 |
commit | 63fe8ed3aa16f2abae79a72b1f9f5ce40fd834df (patch) | |
tree | 6a6c08a86b157ad9f68e7e68e86038aaf77db028 /app/models/issue_relation.rb | |
parent | fc6816629b5c6bf8aaf8124981d1b767e6c4d6bc (diff) | |
download | redmine-63fe8ed3aa16f2abae79a72b1f9f5ce40fd834df.tar.gz redmine-63fe8ed3aa16f2abae79a72b1f9f5ce40fd834df.zip |
Merged r17056 to 3.3-stable (#27663).
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@17058 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue_relation.rb')
-rw-r--r-- | app/models/issue_relation.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/issue_relation.rb b/app/models/issue_relation.rb index ee3a642a1..51d97f6a0 100644 --- a/app/models/issue_relation.rb +++ b/app/models/issue_relation.rb @@ -204,13 +204,19 @@ class IssueRelation < ActiveRecord::Base # Reverses the relation if needed so that it gets stored in the proper way # Should not be reversed before validation so that it can be displayed back - # as entered on new relation form + # as entered on new relation form. + # + # Orders relates relations by ID, so that uniqueness index in DB is triggered + # on concurrent access. def reverse_if_needed if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse] issue_tmp = issue_to self.issue_to = issue_from self.issue_from = issue_tmp self.relation_type = TYPES[relation_type][:reverse] + + elsif relation_type == TYPE_RELATES && issue_from_id > issue_to_id + self.issue_to, self.issue_from = issue_from, issue_to end end @@ -225,6 +231,8 @@ class IssueRelation < ActiveRecord::Base issue_from.blocks? issue_to when 'blocks' issue_to.blocks? issue_from + when 'relates' + self.class.where(issue_from_id: issue_to, issue_to_id: issue_from).present? else false end |