Fixed Rails namespace lookup issue and removed remaining foreign key records in Token table when deleting a user.

This commit is contained in:
Thorsten Eckel 2018-09-10 14:35:12 +02:00 committed by Jens Pfeifer
parent 9d860fbc03
commit ccbf10cb7a
2 changed files with 4 additions and 0 deletions

View file

@ -1166,6 +1166,7 @@ raise 'Minimum one user need to have admin permissions'
::OnlineNotification.where(user_id: id).destroy_all ::OnlineNotification.where(user_id: id).destroy_all
::RecentView.where(created_by_id: id).destroy_all ::RecentView.where(created_by_id: id).destroy_all
::UserDevice.remove(id) ::UserDevice.remove(id)
::Token.where(user_id: id).destroy_all
true true
end end

View file

@ -1258,6 +1258,8 @@ class UserTest < ActiveSupport::TestCase
RecentView.log(ticket1.class.to_s, ticket1.id, agent1) RecentView.log(ticket1.class.to_s, ticket1.id, agent1)
assert_equal(1, RecentView.where(created_by_id: agent1_id).count) assert_equal(1, RecentView.where(created_by_id: agent1_id).count)
Token.create!(action: 'api', user_id: agent1_id)
agent1.destroy! agent1.destroy!
assert_equal(0, UserDevice.where(user_id: agent1_id).count) 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, Cti::CallerId.where(user_id: agent1_id).count)
assert_equal(0, Taskbar.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, RecentView.where(created_by_id: agent1_id).count)
assert_equal(0, Token.where(user_id: agent1_id).count)
end end
test 'adding group drops cache' do test 'adding group drops cache' do