summaryrefslogtreecommitdiffstats
path: root/test/functional/users_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-01-16 15:23:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-01-16 15:23:11 +0000
commite9f62d1209bfa81df33bcb390eb67ba4cab90c0a (patch)
tree40dff8ceb02a30dce788799904d4a8c145d0d6e2 /test/functional/users_controller_test.rb
parent0e3017dc62c672a291cda6053aaba6bda39b2de4 (diff)
downloadredmine-e9f62d1209bfa81df33bcb390eb67ba4cab90c0a.tar.gz
redmine-e9f62d1209bfa81df33bcb390eb67ba4cab90c0a.zip
Enable ability for administrators to delete users (#7296).
User's personal data (eg. preferences, tokens, private queries...) are deleted, public data (eg. issues, wiki edits, attachments...) are reassigned to the anonymous user. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4729 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/users_controller_test.rb')
-rw-r--r--test/functional/users_controller_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 8aa311ebb..6837deab4 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -264,6 +264,30 @@ class UsersControllerTest < ActionController::TestCase
assert u.check_password?('newpass')
end
+ def test_destroy
+ assert_difference 'User.count', -1 do
+ delete :destroy, :id => 2
+ end
+ assert_redirected_to '/users'
+ assert_nil User.find_by_id(2)
+ end
+
+ def test_destroy_should_not_accept_get_requests
+ assert_no_difference 'User.count' do
+ get :destroy, :id => 2
+ end
+ assert_response 405
+ end
+
+ def test_destroy_should_be_denied_for_non_admin_users
+ @request.session[:user_id] = 3
+
+ assert_no_difference 'User.count' do
+ get :destroy, :id => 2
+ end
+ assert_response 403
+ end
+
def test_edit_membership
post :edit_membership, :id => 2, :membership_id => 1,
:membership => { :role_ids => [2]}