Merged r18008 from trunk to 4.0-stable (#31087).

git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@18009 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2019-03-26 14:39:58 +00:00
parent f3232146ac
commit 1d6258250c
2 changed files with 8 additions and 1 deletions

View File

@@ -351,7 +351,7 @@ class Version < ActiveRecord::Base
end
def deletable?
fixed_issues.empty? && !referenced_by_a_custom_field?
fixed_issues.empty? && !referenced_by_a_custom_field? && attachments.empty?
end
def default_project_version

View File

@@ -278,6 +278,13 @@ class VersionTest < ActiveSupport::TestCase
assert_equal false, version.deletable?
end
def test_deletable_should_return_false_when_referenced_by_an_attachment
version = Version.generate!
Attachment.generate!(:container => version, :filename => 'test.txt')
assert_equal false, version.deletable?
end
def test_like_scope
version = Version.create!(:project => Project.find(1), :name => 'Version for like scope test')