Project

General

Profile

Defect #34108 » fixed-34108.patch

Yuichi HARADA, 2020-10-13 09:13

View differences:

app/models/issue_relation.rb
239 239
      issue_from.blocks? issue_to
240 240
    when 'blocks'
241 241
      issue_to.blocks? issue_from
242
    when 'duplicated'
243
      self.class.where(issue_from_id: issue_from, issue_to_id: issue_to, relation_type: TYPE_DUPLICATES).exists?
244
    when 'duplicates'
245
      self.class.where(issue_from_id: issue_to, issue_to_id: issue_from, relation_type: TYPE_DUPLICATES).exists?
242 246
    when 'relates'
243 247
      self.class.where(issue_from_id: issue_to, issue_to_id: issue_from).present?
244 248
    else
test/unit/issue_relation_test.rb
189 189
    assert_not_equal [], r.errors[:base]
190 190
  end
191 191

  
192
  def test_validates_circular_dependency_on_reverse_relations_using_duplicates
193
    with_locale 'en' do
194
      IssueRelation.delete_all
195
      issue1 = issues(:issues_001)
196
      issue2 = issues(:issues_002)
197
      assert IssueRelation.create!(
198
              :issue_from => issue1, :issue_to => issue2,
199
              :relation_type => IssueRelation::TYPE_DUPLICATES
200
            )
201
      r = IssueRelation.new(
202
            :issue_from => issue2, :issue_to => issue1,
203
            :relation_type => IssueRelation::TYPE_DUPLICATES
204
          )
205
      assert !r.save
206
      assert_include 'This relation would create a circular dependency', r.errors.full_messages
207
    end
208
  end
209

  
192 210
  def test_create_with_initialized_journals_should_create_journals
193 211
    from = Issue.find(1)
194 212
    to   = Issue.find(2)
(2-2/4)