diff --git a/app/models/user.rb b/app/models/user.rb index 281bd8d25..515243d77 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1166,6 +1166,7 @@ raise 'Minimum one user need to have admin permissions' ::OnlineNotification.where(user_id: id).destroy_all ::RecentView.where(created_by_id: id).destroy_all ::UserDevice.remove(id) + ::Token.where(user_id: id).destroy_all true end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 7c0fbfcdf..194284dd2 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -1258,6 +1258,8 @@ class UserTest < ActiveSupport::TestCase RecentView.log(ticket1.class.to_s, ticket1.id, agent1) assert_equal(1, RecentView.where(created_by_id: agent1_id).count) + Token.create!(action: 'api', user_id: agent1_id) + agent1.destroy! assert_equal(0, UserDevice.where(user_id: agent1_id).count) @@ -1268,6 +1270,7 @@ class UserTest < ActiveSupport::TestCase assert_equal(0, Cti::CallerId.where(user_id: agent1_id).count) assert_equal(0, Taskbar.where(user_id: agent1_id).count) assert_equal(0, RecentView.where(created_by_id: agent1_id).count) + assert_equal(0, Token.where(user_id: agent1_id).count) end test 'adding group drops cache' do