Adds the ability for users to delete their own account (#10664). Can be disabled in application settings.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9417 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-04-15 14:31:54 +00:00
parent 638583012a
commit 28f0c4f131
14 changed files with 133 additions and 8 deletions
+27
View File
@@ -770,7 +770,34 @@ class UserTest < ActiveSupport::TestCase
user.auth_source = denied_auth_source
assert !user.change_password_allowed?, "User allowed to change password, though auth source does not"
end
end
def test_own_account_deletable_should_be_true_with_unsubscrive_enabled
with_settings :unsubscribe => '1' do
assert_equal true, User.find(2).own_account_deletable?
end
end
def test_own_account_deletable_should_be_false_with_unsubscrive_disabled
with_settings :unsubscribe => '0' do
assert_equal false, User.find(2).own_account_deletable?
end
end
def test_own_account_deletable_should_be_false_for_a_single_admin
User.delete_all(["admin = ? AND id <> ?", true, 1])
with_settings :unsubscribe => '1' do
assert_equal false, User.find(1).own_account_deletable?
end
end
def test_own_account_deletable_should_be_true_for_an_admin_if_other_admin_exists
User.generate_with_protected(:admin => true)
with_settings :unsubscribe => '1' do
assert_equal true, User.find(1).own_account_deletable?
end
end
context "#allowed_to?" do