diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-12-12 10:06:07 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-12-12 10:06:07 +0000 |
commit | 5c6ce51ec9f1f3f6687db06d0faeb61d1524198d (patch) | |
tree | 34b9083d62a6f99dbc297837f7f93ea11e0cf813 /test/functional/workflows_controller_test.rb | |
parent | ddeaf9da965c1145e65c1552414b3432a5291ea1 (diff) | |
download | redmine-5c6ce51ec9f1f3f6687db06d0faeb61d1524198d.tar.gz redmine-5c6ce51ec9f1f3f6687db06d0faeb61d1524198d.zip |
Adds workflow copy functionality (#1727).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3154 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/workflows_controller_test.rb')
-rw-r--r-- | test/functional/workflows_controller_test.rb | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb index 19187b7fe..2b5216f55 100644 --- a/test/functional/workflows_controller_test.rb +++ b/test/functional/workflows_controller_test.rb @@ -22,7 +22,7 @@ require 'workflows_controller' class WorkflowsController; def rescue_action(e) raise e end; end class WorkflowsControllerTest < ActionController::TestCase - fixtures :roles, :trackers, :workflows + fixtures :roles, :trackers, :workflows, :users def setup @controller = WorkflowsController.new @@ -81,4 +81,50 @@ class WorkflowsControllerTest < ActionController::TestCase post :edit, :role_id => 2, :tracker_id => 1 assert_equal 0, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2}) end + + def test_get_copy + get :copy + assert_response :success + assert_template 'copy' + end + + def test_post_copy_one_to_one + source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) + + post :copy, :source_tracker_id => '1', :source_role_id => '2', + :target_tracker_ids => ['3'], :target_role_ids => ['1'] + assert_response 302 + assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) + end + + def test_post_copy_one_to_many + source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) + + post :copy, :source_tracker_id => '1', :source_role_id => '2', + :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] + assert_response 302 + assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 1) + assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) + assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 3) + assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 3) + end + + def test_post_copy_many_to_many + source_t2 = status_transitions(:tracker_id => 2, :role_id => 2) + source_t3 = status_transitions(:tracker_id => 3, :role_id => 2) + + post :copy, :source_tracker_id => 'any', :source_role_id => '2', + :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] + assert_response 302 + assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 1) + assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 1) + assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 3) + assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 3) + end + + # Returns an array of status transitions that can be compared + def status_transitions(conditions) + Workflow.find(:all, :conditions => conditions, + :order => 'tracker_id, role_id, old_status_id, new_status_id').collect {|w| [w.old_status, w.new_status_id]} + end end |