##// END OF EJS Templates
Upgraded to Rails 2.3.4 (#3597)...
Upgraded to Rails 2.3.4 (#3597) * Ran the Rails upgrade * Upgraded to Rails Engines 2.3.2 * Added a plugin to let Engines override application views. * Converted tests to use the new classes: ** ActionController::TestCase for functional ** ActiveSupport::TestCase for units * Converted ActiveRecord::Error message to a string. * ActiveRecord grouping returns an ordered hash which doesn't have #sort! * Updated the I18n storage_units format. * Added some default initializers from a fresh rails app * Changed the order of check_box_tags and hidden_field_tags. The hidden tag needs to appear first in Rails 2.3, otherwise it will override any value in the check_box_tag. * Removed the custom handler for when the cookie store is tampered with. Rails 2.3 removed the TamperedWithCookie exception and instead Rails will not load the data from it when it's been tampered with (e.g. no user login). * Fixed mail layouts, 2.3 has problems with implicit multipart emails that use layouts. Also removed some custom Redmine mailer code. * Fixed a bug that occurred in tests where the "required" span tag would be added to the :field_status translation. This resulted in an email string of: <li>Status<span class="required"> *</span><span class="required"> *</span> Instead of: <li>Status: New</li> git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2887 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r2773:7b0cb6aba871
r2773:7b0cb6aba871
Show More
roles_controller_test.rb
180 lines | 5.9 KiB | text/x-ruby | RubyLexer
/ test / functional / roles_controller_test.rb
Jean-Philippe Lang
Workflow copy:...
r1237 # 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
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 class RolesControllerTest < ActionController::TestCase
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 fixtures :roles, :users, :members, :member_roles, :workflows
Jean-Philippe Lang
Workflow copy:...
r1237
def setup
@controller = RolesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
@request.session[:user_id] = 1 # admin
end
Jean-Philippe Lang
Add some tests on RolesController....
r1254 def test_get_index
get :index
assert_response :success
assert_template 'list'
assert_not_nil assigns(:roles)
assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles)
assert_tag :tag => 'a', :attributes => { :href => '/roles/edit/1' },
:content => 'Manager'
end
Jean-Philippe Lang
Workflow copy:...
r1237 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'}
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Workflow copy:...
r1237 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'
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Workflow copy:...
r1237 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'}
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Workflow copy:...
r1237 role = Role.find(1)
assert_equal [:edit_project], role.permissions
end
Jean-Philippe Lang
Add some tests on RolesController....
r1254
def test_destroy
r = Role.new(:name => 'ToBeDestroyed', :permissions => [:view_wiki_pages])
assert r.save
post :destroy, :id => r
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Add some tests on RolesController....
r1254 assert_nil Role.find_by_id(r.id)
end
def test_destroy_role_in_use
post :destroy, :id => 1
assert_redirected_to 'roles'
assert flash[:error] == 'This role is in use and can not be deleted.'
assert_not_nil Role.find_by_id(1)
end
def test_get_report
get :report
assert_response :success
assert_template 'report'
assert_not_nil assigns(:roles)
assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles)
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'permissions[3][]',
:value => 'add_issues',
:checked => 'checked' }
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'permissions[3][]',
:value => 'delete_issues',
:checked => nil }
end
def test_post_report
post :report, :permissions => { '0' => '', '1' => ['edit_issues'], '3' => ['add_issues', 'delete_issues']}
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Add some tests on RolesController....
r1254
assert_equal [:edit_issues], Role.find(1).permissions
assert_equal [:add_issues, :delete_issues], Role.find(3).permissions
assert Role.find(2).permissions.empty?
end
def test_clear_all_permissions
post :report, :permissions => { '0' => '' }
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Add some tests on RolesController....
r1254 assert Role.find(1).permissions.empty?
end
def test_move_highest
Jean-Philippe Lang
Reorder links refactoring (follows r2526)....
r2478 post :edit, :id => 3, :role => {:move_to => 'highest'}
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Add some tests on RolesController....
r1254 assert_equal 1, Role.find(3).position
end
def test_move_higher
position = Role.find(3).position
Jean-Philippe Lang
Reorder links refactoring (follows r2526)....
r2478 post :edit, :id => 3, :role => {:move_to => 'higher'}
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Add some tests on RolesController....
r1254 assert_equal position - 1, Role.find(3).position
end
def test_move_lower
position = Role.find(2).position
Jean-Philippe Lang
Reorder links refactoring (follows r2526)....
r2478 post :edit, :id => 2, :role => {:move_to => 'lower'}
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Add some tests on RolesController....
r1254 assert_equal position + 1, Role.find(2).position
end
def test_move_lowest
Jean-Philippe Lang
Reorder links refactoring (follows r2526)....
r2478 post :edit, :id => 2, :role => {:move_to => 'lowest'}
Jean-Philippe Lang
Allows multiple roles on the same project (#706). Prerequisite for user groups feature....
r2627 assert_redirected_to 'roles'
Jean-Philippe Lang
Add some tests on RolesController....
r1254 assert_equal Role.count, Role.find(2).position
end
Jean-Philippe Lang
Workflow copy:...
r1237 end