summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-08 13:03:41 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-08 13:03:41 +0000
commitd201c54455fd15d0069de5a60bc99a57cc380ba3 (patch)
treeef8c74e1de77b36bb2548c43a09a21897b9c41ec /test
parent7c14c6d42e469f1cd81b08c059a9717566fe4e1f (diff)
downloadredmine-d201c54455fd15d0069de5a60bc99a57cc380ba3.tar.gz
redmine-d201c54455fd15d0069de5a60bc99a57cc380ba3.zip
Adds version status to limit issue assignments (#1245).
Available version statuses are: * open: no restriction * locked: can not assign new issues to the version * closed: can not assign new issues and can not reopen assigned issues git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3020 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/issues.yml32
-rw-r--r--test/fixtures/versions.yml3
-rw-r--r--test/unit/issue_test.rb51
-rw-r--r--test/unit/version_test.rb1
4 files changed, 87 insertions, 0 deletions
diff --git a/test/fixtures/issues.yml b/test/fixtures/issues.yml
index f7917639b..03197458d 100644
--- a/test/fixtures/issues.yml
+++ b/test/fixtures/issues.yml
@@ -157,3 +157,35 @@ issues_010:
status_id: 1
start_date: <%= Date.today.to_s(:db) %>
due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
+issues_011:
+ created_on: <%= 3.days.ago.to_date.to_s(:db) %>
+ project_id: 1
+ updated_on: <%= 1.day.ago.to_date.to_s(:db) %>
+ priority_id: 5
+ subject: Closed issue on a closed version
+ id: 11
+ fixed_version_id: 1
+ category_id: 1
+ description:
+ tracker_id: 1
+ assigned_to_id:
+ author_id: 2
+ status_id: 5
+ start_date: <%= 1.day.ago.to_date.to_s(:db) %>
+ due_date:
+issues_012:
+ created_on: <%= 3.days.ago.to_date.to_s(:db) %>
+ project_id: 1
+ updated_on: <%= 1.day.ago.to_date.to_s(:db) %>
+ priority_id: 5
+ subject: Closed issue on a locked version
+ id: 12
+ fixed_version_id: 2
+ category_id: 1
+ description:
+ tracker_id: 1
+ assigned_to_id:
+ author_id: 2
+ status_id: 5
+ start_date: <%= 1.day.ago.to_date.to_s(:db) %>
+ due_date:
diff --git a/test/fixtures/versions.yml b/test/fixtures/versions.yml
index 9306811f2..bcecb67d5 100644
--- a/test/fixtures/versions.yml
+++ b/test/fixtures/versions.yml
@@ -7,6 +7,7 @@ versions_001:
id: 1
description: Beta
effective_date: 2006-07-01
+ status: closed
versions_002:
created_on: 2006-07-19 21:00:33 +02:00
name: "1.0"
@@ -15,6 +16,7 @@ versions_002:
id: 2
description: Stable release
effective_date: <%= 20.day.from_now.to_date.to_s(:db) %>
+ status: locked
versions_003:
created_on: 2006-07-19 21:00:33 +02:00
name: "2.0"
@@ -23,4 +25,5 @@ versions_003:
id: 3
description: Future version
effective_date:
+ status: open
\ No newline at end of file
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 147d31f8c..a8010cf48 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -20,6 +20,7 @@ require File.dirname(__FILE__) + '/../test_helper'
class IssueTest < ActiveSupport::TestCase
fixtures :projects, :users, :members, :member_roles,
:trackers, :projects_trackers,
+ :versions,
:issue_statuses, :issue_categories, :issue_relations, :workflows,
:enumerations,
:issues,
@@ -184,6 +185,56 @@ class IssueTest < ActiveSupport::TestCase
assert !issue1.reload.closed?
end
+ def test_assignable_versions
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
+ assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
+ end
+
+ def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
+ assert !issue.save
+ assert_not_nil issue.errors.on(:fixed_version_id)
+ end
+
+ def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 2, :subject => 'New issue')
+ assert !issue.save
+ assert_not_nil issue.errors.on(:fixed_version_id)
+ end
+
+ def test_should_be_able_to_assign_a_new_issue_to_an_open_version
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 3, :subject => 'New issue')
+ assert issue.save
+ end
+
+ def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
+ issue = Issue.find(11)
+ assert_equal 'closed', issue.fixed_version.status
+ issue.subject = 'Subject changed'
+ assert issue.save
+ end
+
+ def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
+ issue = Issue.find(11)
+ issue.status_id = 1
+ assert !issue.save
+ assert_not_nil issue.errors.on_base
+ end
+
+ def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
+ issue = Issue.find(11)
+ issue.status_id = 1
+ issue.fixed_version_id = 3
+ assert issue.save
+ end
+
+ def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
+ issue = Issue.find(12)
+ assert_equal 'locked', issue.fixed_version.status
+ issue.status_id = 1
+ assert issue.save
+ end
+
def test_move_to_another_project_with_same_category
issue = Issue.find(1)
assert issue.move_to(Project.find(2))
diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb
index 7df857927..5702fd181 100644
--- a/test/unit/version_test.rb
+++ b/test/unit/version_test.rb
@@ -26,6 +26,7 @@ class VersionTest < ActiveSupport::TestCase
def test_create
v = Version.new(:project => Project.find(1), :name => '1.1', :effective_date => '2011-03-25')
assert v.save
+ assert_equal 'open', v.status
end
def test_invalid_effective_date_validation