From 6c8e0ce176c03c70a53e7bea1f115d728dc37850 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Tue, 18 Aug 2020 14:49:37 +0300 Subject: [PATCH] Add tests --- test/controllers/users_controller_test.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index c3dde992..13ee8db6 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -36,7 +36,7 @@ class UsersControllerTest < ActionController::TestCase assert_equal assigns['users'],[User.where(:login => 'jane').first] end - def test_destroy_user + def test_destroy_user_as_admin login_as :admin_user @no_users_before = User.count user_id = users(:ldap_user).id @@ -44,8 +44,16 @@ class UsersControllerTest < ActionController::TestCase assert_equal @no_users_before-1, User.count end + def test_destroy_user_as_user + login_as :other_user + @no_users_before = User.count + user_id = users(:other_user).id + post :destroy, xhr: true, params: { :id => user_id.to_param } + assert_equal @no_users_before-1, User.count + end + def test_update_password_successful - get :change_password, params: { :id => users(:admin_user).id } + get :change_password, params: { :id => users(:admin_user).id } # should fail because no login assert_redirected_to login_path login_as :admin_user