Fixes #3585 - DataPrivacy may fail to clear user relations.
This commit is contained in:
parent
9e4fae6360
commit
649dff172e
3 changed files with 9 additions and 3 deletions
|
@ -1176,7 +1176,7 @@ raise 'Minimum one user need to have admin permissions'
|
||||||
def destroy_move_dependency_ownership
|
def destroy_move_dependency_ownership
|
||||||
result = Models.references(self.class.to_s, id)
|
result = Models.references(self.class.to_s, id)
|
||||||
|
|
||||||
user_columns = %w[created_by_id updated_by_id origin_by_id owner_id archived_by_id published_by_id internal_by_id]
|
user_columns = %w[created_by_id updated_by_id out_of_office_replacement_id origin_by_id owner_id archived_by_id published_by_id internal_by_id]
|
||||||
result.each do |class_name, references|
|
result.each do |class_name, references|
|
||||||
next if class_name.blank?
|
next if class_name.blank?
|
||||||
next if references.blank?
|
next if references.blank?
|
||||||
|
|
|
@ -133,6 +133,7 @@ returns
|
||||||
if object_name == 'User'
|
if object_name == 'User'
|
||||||
ref_attributes.push 'created_by_id'
|
ref_attributes.push 'created_by_id'
|
||||||
ref_attributes.push 'updated_by_id'
|
ref_attributes.push 'updated_by_id'
|
||||||
|
ref_attributes.push 'out_of_office_replacement_id'
|
||||||
end
|
end
|
||||||
list.each do |model_class, model_attributes|
|
list.each do |model_class, model_attributes|
|
||||||
if !references[model_class.to_s]
|
if !references[model_class.to_s]
|
||||||
|
|
|
@ -868,13 +868,13 @@ RSpec.describe User, type: :model do
|
||||||
'Trigger' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'Trigger' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
||||||
'Translation' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'Translation' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
||||||
'ObjectManager::Attribute' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'ObjectManager::Attribute' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
||||||
'User' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'User' => { 'created_by_id' => 1, 'out_of_office_replacement_id' => 1, 'updated_by_id' => 1 },
|
||||||
'Organization' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'Organization' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
||||||
'Macro' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'Macro' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
||||||
'Mention' => { 'created_by_id' => 1, 'updated_by_id' => 0, 'user_id' => 1 },
|
'Mention' => { 'created_by_id' => 1, 'updated_by_id' => 0, 'user_id' => 1 },
|
||||||
'Channel' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'Channel' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
||||||
'Role' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'Role' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
||||||
'History' => { 'created_by_id' => 3 },
|
'History' => { 'created_by_id' => 4 },
|
||||||
'Webhook' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
'Webhook' => { 'created_by_id' => 0, 'updated_by_id' => 0 },
|
||||||
'Overview' => { 'created_by_id' => 1, 'updated_by_id' => 0 },
|
'Overview' => { 'created_by_id' => 1, 'updated_by_id' => 0 },
|
||||||
'ActivityStream' => { 'created_by_id' => 0 },
|
'ActivityStream' => { 'created_by_id' => 0 },
|
||||||
|
@ -898,6 +898,7 @@ RSpec.describe User, type: :model do
|
||||||
overview = create(:overview, created_by_id: user.id, user_ids: [user.id])
|
overview = create(:overview, created_by_id: user.id, user_ids: [user.id])
|
||||||
mention = create(:mention, mentionable: create(:ticket), user: user)
|
mention = create(:mention, mentionable: create(:ticket), user: user)
|
||||||
mention_created_by = create(:mention, mentionable: create(:ticket), user: create(:agent), created_by: user)
|
mention_created_by = create(:mention, mentionable: create(:ticket), user: create(:agent), created_by: user)
|
||||||
|
user_created_by = create(:customer, created_by_id: user.id, updated_by_id: user.id, out_of_office_replacement_id: user.id)
|
||||||
expect(overview.reload.user_ids).to eq([user.id])
|
expect(overview.reload.user_ids).to eq([user.id])
|
||||||
|
|
||||||
# create a chat agent for admin user (id=1) before agent user
|
# create a chat agent for admin user (id=1) before agent user
|
||||||
|
@ -951,6 +952,10 @@ RSpec.describe User, type: :model do
|
||||||
.to change(knowledge_base_answer, :archived_by_id).to(1)
|
.to change(knowledge_base_answer, :archived_by_id).to(1)
|
||||||
.and change(knowledge_base_answer, :published_by_id).to(1)
|
.and change(knowledge_base_answer, :published_by_id).to(1)
|
||||||
.and change(knowledge_base_answer, :internal_by_id).to(1)
|
.and change(knowledge_base_answer, :internal_by_id).to(1)
|
||||||
|
expect { user_created_by.reload }
|
||||||
|
.to change(user_created_by, :created_by_id).to(1)
|
||||||
|
.and change(user_created_by, :updated_by_id).to(1)
|
||||||
|
.and change(user_created_by, :out_of_office_replacement_id).to(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does delete cache after user deletion' do
|
it 'does delete cache after user deletion' do
|
||||||
|
|
Loading…
Reference in a new issue