summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-15 08:27:38 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-15 08:27:38 +0000
commitaec989707edc47161192eba74f1a88123b12360a (patch)
tree5a810a6a3fb4fb76b9cfdb439eedc666bf4d049a /test
parent993b60d61eb927cff21ea0b06c1631eb986f6a51 (diff)
downloadredmine-aec989707edc47161192eba74f1a88123b12360a.tar.gz
redmine-aec989707edc47161192eba74f1a88123b12360a.zip
Workflow copy:
* added the ability the copy an existing workflow when creating a new role (closes #841) * use a single raw insert statement to copy tracker/role workflow rather than instantiating hundreds/thousands of objects git-svn-id: http://redmine.rubyforge.org/svn/trunk@1252 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/roles_controller_test.rb92
-rw-r--r--test/unit/role_test.rb33
-rw-r--r--test/unit/tracker_test.rb33
3 files changed, 158 insertions, 0 deletions
diff --git a/test/functional/roles_controller_test.rb b/test/functional/roles_controller_test.rb
new file mode 100644
index 000000000..3c245edf7
--- /dev/null
+++ b/test/functional/roles_controller_test.rb
@@ -0,0 +1,92 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper'
+require 'roles_controller'
+
+# Re-raise errors caught by the controller.
+class RolesController; def rescue_action(e) raise e end; end
+
+class RolesControllerTest < Test::Unit::TestCase
+ fixtures :roles, :users, :members, :workflows
+
+ def setup
+ @controller = RolesController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ @request.session[:user_id] = 1 # admin
+ end
+
+ def test_get_new
+ get :new
+ assert_response :success
+ assert_template 'new'
+ end
+
+ def test_post_new_with_validaton_failure
+ post :new, :role => {:name => '',
+ :permissions => ['add_issues', 'edit_issues', 'log_time', ''],
+ :assignable => '0'}
+
+ assert_response :success
+ assert_template 'new'
+ assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' }
+ end
+
+ def test_post_new_without_workflow_copy
+ post :new, :role => {:name => 'RoleWithoutWorkflowCopy',
+ :permissions => ['add_issues', 'edit_issues', 'log_time', ''],
+ :assignable => '0'}
+
+ assert_redirected_to 'roles/list'
+ role = Role.find_by_name('RoleWithoutWorkflowCopy')
+ assert_not_nil role
+ assert_equal [:add_issues, :edit_issues, :log_time], role.permissions
+ assert !role.assignable?
+ end
+
+ def test_post_new_with_workflow_copy
+ post :new, :role => {:name => 'RoleWithWorkflowCopy',
+ :permissions => ['add_issues', 'edit_issues', 'log_time', ''],
+ :assignable => '0'},
+ :copy_workflow_from => '1'
+
+ assert_redirected_to 'roles/list'
+ role = Role.find_by_name('RoleWithWorkflowCopy')
+ assert_not_nil role
+ assert_equal Role.find(1).workflows.size, role.workflows.size
+ end
+
+ def test_get_edit
+ get :edit, :id => 1
+ assert_response :success
+ assert_template 'edit'
+ assert_equal Role.find(1), assigns(:role)
+ end
+
+ def test_post_edit
+ post :edit, :id => 1,
+ :role => {:name => 'Manager',
+ :permissions => ['edit_project', ''],
+ :assignable => '0'}
+
+ assert_redirected_to 'roles/list'
+ role = Role.find(1)
+ assert_equal [:edit_project], role.permissions
+ end
+end
diff --git a/test/unit/role_test.rb b/test/unit/role_test.rb
new file mode 100644
index 000000000..5e0d16753
--- /dev/null
+++ b/test/unit/role_test.rb
@@ -0,0 +1,33 @@
+# redMine - project management software
+# Copyright (C) 2006-2008 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.dirname(__FILE__) + '/../test_helper'
+
+class RoleTest < Test::Unit::TestCase
+ fixtures :roles, :workflows
+
+ def test_copy_workflows
+ source = Role.find(1)
+ assert_equal 90, source.workflows.size
+
+ target = Role.new(:name => 'Target')
+ assert target.save
+ assert target.workflows.copy(source)
+ target.reload
+ assert_equal 90, target.workflows.size
+ end
+end
diff --git a/test/unit/tracker_test.rb b/test/unit/tracker_test.rb
new file mode 100644
index 000000000..7adacef3c
--- /dev/null
+++ b/test/unit/tracker_test.rb
@@ -0,0 +1,33 @@
+# redMine - project management software
+# Copyright (C) 2006-2008 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.dirname(__FILE__) + '/../test_helper'
+
+class TrackerTest < Test::Unit::TestCase
+ fixtures :trackers, :workflows
+
+ def test_copy_workflows
+ source = Tracker.find(1)
+ assert_equal 90, source.workflows.size
+
+ target = Tracker.new(:name => 'Target')
+ assert target.save
+ assert target.workflows.copy(source)
+ target.reload
+ assert_equal 90, target.workflows.size
+ end
+end