summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/object_helpers.rb1
-rw-r--r--test/unit/version_test.rb21
2 files changed, 22 insertions, 0 deletions
diff --git a/test/object_helpers.rb b/test/object_helpers.rb
index 7061e75c1..74f82b68b 100644
--- a/test/object_helpers.rb
+++ b/test/object_helpers.rb
@@ -125,6 +125,7 @@ module ObjectHelpers
@generated_version_name.succ!
version = Version.new(attributes)
version.name = @generated_version_name.dup if version.name.blank?
+ version.project ||= Project.find(1)
yield version if block_given?
version.save!
version
diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb
index 6c1238eb0..b61061b85 100644
--- a/test/unit/version_test.rb
+++ b/test/unit/version_test.rb
@@ -235,6 +235,27 @@ class VersionTest < ActiveSupport::TestCase
assert_equal @version, project_2_issue.fixed_version
end
+ def test_deletable_should_return_true_when_not_referenced
+ version = Version.generate!
+
+ assert_equal true, version.deletable?
+ end
+
+ def test_deletable_should_return_false_when_referenced_by_an_issue
+ version = Version.generate!
+ Issue.generate!(:fixed_version => version)
+
+ assert_equal false, version.deletable?
+ end
+
+ def test_deletable_should_return_false_when_referenced_by_a_custom_field
+ version = Version.generate!
+ field = IssueCustomField.generate!(:field_format => 'version')
+ value = CustomValue.create!(:custom_field => field, :customized => Issue.first, :value => version.id)
+
+ assert_equal false, version.deletable?
+ end
+
private
def add_issue(version, attributes={})