From 1d6258250ccfadb3213a300db63afaeb9ef38441 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Tue, 26 Mar 2019 14:39:58 +0000 Subject: [PATCH] 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 --- app/models/version.rb | 2 +- test/unit/version_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/version.rb b/app/models/version.rb index 2ccea2fda..d4598eed8 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -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 diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb index b05096067..e3e52b33d 100644 --- a/test/unit/version_test.rb +++ b/test/unit/version_test.rb @@ -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') -- 2.39.5