diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-11-08 13:03:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-11-08 13:03:41 +0000 |
commit | d201c54455fd15d0069de5a60bc99a57cc380ba3 (patch) | |
tree | ef8c74e1de77b36bb2548c43a09a21897b9c41ec /test/unit/issue_test.rb | |
parent | 7c14c6d42e469f1cd81b08c059a9717566fe4e1f (diff) | |
download | redmine-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/unit/issue_test.rb')
-rw-r--r-- | test/unit/issue_test.rb | 51 |
1 files changed, 51 insertions, 0 deletions
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)) |