summaryrefslogtreecommitdiffstats
path: root/test/unit/user_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-15 14:31:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-15 14:31:54 +0000
commit28f0c4f131b02ab67bd9c254f9853168ec6a5b65 (patch)
treefeedcef78913a173d5f8776c3f13e0f8990c317b /test/unit/user_test.rb
parent638583012ae165e5cb197fb3b4d7a0fe54318217 (diff)
downloadredmine-28f0c4f131b02ab67bd9c254f9853168ec6a5b65.tar.gz
redmine-28f0c4f131b02ab67bd9c254f9853168ec6a5b65.zip
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
Diffstat (limited to 'test/unit/user_test.rb')
-rw-r--r--test/unit/user_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index e698207da..607f23770 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -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