summaryrefslogtreecommitdiffstats
path: root/test/functional/users_controller_test.rb
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2024-06-25 19:03:36 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2024-06-25 19:03:36 +0000
commit193ca9faee467e8b9e0b912026f956da8c4a0fdb (patch)
tree100fac98389fb990b0a21d77c98d1ac412237f0a /test/functional/users_controller_test.rb
parent0afa535765599073d0f92f2029ea28e98d8dfcdd (diff)
downloadredmine-193ca9faee467e8b9e0b912026f956da8c4a0fdb.tar.gz
redmine-193ca9faee467e8b9e0b912026f956da8c4a0fdb.zip
Add bulk lock feature to user list context menu (#40913).
Patch by Mizuki ISHIKAWA (@ishikawa999). git-svn-id: https://svn.redmine.org/redmine/trunk@22898 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/users_controller_test.rb')
-rw-r--r--test/functional/users_controller_test.rb42
1 files changed, 34 insertions, 8 deletions
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index b869db0d0..b56fb9108 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -1145,14 +1145,6 @@ class UsersControllerTest < Redmine::ControllerTest
assert_nil User.find_by_id(2)
end
- def test_bulk_destroy_with_lock_param_should_lock_instead
- assert_no_difference 'User.count' do
- delete :bulk_destroy, :params => {:ids => [2], :lock => 'lock'}
- end
- assert_redirected_to '/users'
- assert User.find_by_id(2).locked?
- end
-
def test_bulk_destroy_should_require_confirmation
assert_no_difference 'User.count' do
delete :bulk_destroy, :params => {:ids => [2]}
@@ -1185,4 +1177,38 @@ class UsersControllerTest < Redmine::ControllerTest
end
assert_response :not_found
end
+
+ def test_bulk_lock
+ assert_difference 'User.status(User::STATUS_LOCKED).count', 1 do
+ delete :bulk_lock, :params => {:ids => [2]}
+ end
+ assert_redirected_to '/users'
+ assert User.find_by_id(2).locked?
+ end
+
+ def test_bulk_lock_should_not_lock_current_user
+ assert_difference 'User.status(User::STATUS_LOCKED).count', 1 do
+ delete :bulk_lock, :params => {:ids => [2, 1]}
+ end
+ assert_redirected_to '/users'
+ assert_not User.find_by_id(1).locked?
+ assert User.find_by_id(2).locked?
+ end
+
+ def test_bulk_lock_should_be_denied_for_non_admin_users
+ @request.session[:user_id] = 3
+
+ assert_no_difference 'User.status(User::STATUS_LOCKED).count' do
+ delete :bulk_lock, :params => {:ids => [2]}
+ end
+ assert_response :forbidden
+ end
+
+ def test_bulk_lock_should_be_denied_for_anonymous
+ assert User.find(6).anonymous?
+ assert_no_difference 'User.status(User::STATUS_LOCKED).count' do
+ delete :bulk_lock, :params => {:ids => [6]}
+ end
+ assert_response :not_found
+ end
end