31087.patch

Takenori TAKAKI, 2019-03-26 09:44

Download (1.03 KB)

View differences:

app/models/version.rb
353 353
  end
354 354

  
355 355
  def deletable?
356
    fixed_issues.empty? && !referenced_by_a_custom_field?
356
    fixed_issues.empty? && !referenced_by_a_custom_field? && attachments.empty?
357 357
  end
358 358

  
359 359
  def default_project_version
test/unit/version_test.rb
284 284
    assert_equal false, version.deletable?
285 285
  end
286 286

  
287
  def test_deletable_should_return_false_when_referenced_by_an_attachment
288
    version = Version.generate!
289
    Attachment.generate!(:container => version, :filename => 'test.txt')
290

  
291
    assert_equal false, version.deletable?
292
  end
293

  
287 294
  def test_like_scope
288 295
    version = Version.create!(:project => Project.find(1), :name => 'Version for like scope test')
289 296