diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-02-25 02:54:47 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-02-25 02:54:47 +0000 |
commit | b6c794d16b47bf353a1a2dfc00e9cbd078525ee8 (patch) | |
tree | 7dec97be4c38b4e3b6321f7c55b81697ca6f5ee2 /test/unit/workflow_transition_test.rb | |
parent | c6f71f727bc73188ce7285c6e19bf50553246ec7 (diff) | |
download | redmine-b6c794d16b47bf353a1a2dfc00e9cbd078525ee8.tar.gz redmine-b6c794d16b47bf353a1a2dfc00e9cbd078525ee8.zip |
Bulk edit workflows for multiple trackers/roles (#16164).
git-svn-id: http://svn.redmine.org/redmine/trunk@12924 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/workflow_transition_test.rb')
-rw-r--r-- | test/unit/workflow_transition_test.rb | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/test/unit/workflow_transition_test.rb b/test/unit/workflow_transition_test.rb new file mode 100644 index 000000000..0b5e1ab1e --- /dev/null +++ b/test/unit/workflow_transition_test.rb @@ -0,0 +1,93 @@ +# Redmine - project management software +# Copyright (C) 2006-2014 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require File.expand_path('../../test_helper', __FILE__) + +class WorkflowTransitionTest < ActiveSupport::TestCase + fixtures :roles, :trackers, :issue_statuses + + def setup + WorkflowTransition.delete_all + end + + def test_replace_transitions_should_create_enabled_transitions + w = WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2) + + transitions = {'1' => { + '2' => {'always' => '1'}, + '3' => {'always' => '1'} + }} + assert_difference 'WorkflowTransition.count' do + WorkflowTransition.replace_transitions(Tracker.find(1), Role.find(1), transitions) + end + assert WorkflowTransition.where(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3).exists? + end + + def test_replace_transitions_should_delete_disabled_transitions + w1 = WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2) + w2 = WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3) + + transitions = {'1' => { + '2' => {'always' => '0'}, + '3' => {'always' => '1'} + }} + assert_difference 'WorkflowTransition.count', -1 do + WorkflowTransition.replace_transitions(Tracker.find(1), Role.find(1), transitions) + end + assert !WorkflowTransition.exists?(w1.id) + end + + def test_replace_transitions_should_create_enabled_additional_transitions + transitions = {'1' => { + '2' => {'always' => '0', 'assignee' => '0', 'author' => '1'} + }} + assert_difference 'WorkflowTransition.count' do + WorkflowTransition.replace_transitions(Tracker.find(1), Role.find(1), transitions) + end + w = WorkflowTransition.where(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2).first + assert w + assert_equal false, w.assignee + assert_equal true, w.author + end + + def test_replace_transitions_should_delete_disabled_additional_transitions + w = WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :assignee => true) + + transitions = {'1' => { + '2' => {'always' => '0', 'assignee' => '0', 'author' => '0'} + }} + assert_difference 'WorkflowTransition.count', -1 do + WorkflowTransition.replace_transitions(Tracker.find(1), Role.find(1), transitions) + end + assert !WorkflowTransition.exists?(w.id) + end + + def test_replace_transitions_should_update_additional_transitions + WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :assignee => true) + + transitions = {'1' => { + '2' => {'always' => '0', 'assignee' => '0', 'author' => '1'} + }} + assert_no_difference 'WorkflowTransition.count' do + WorkflowTransition.replace_transitions(Tracker.find(1), Role.find(1), transitions) + end + w = WorkflowTransition.where(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2).first + assert w + assert_equal false, w.assignee + assert_equal true, w.author + end +end |