Merge pull request #4624 from okriuchykhin/ok_SCI_7457

Fix protocol owner re-assignment when removing a user from a team [SCI-7457]
This commit is contained in:
Alex Kriuchykhin 2022-11-21 11:03:50 +01:00 committed by GitHub
commit d9897d6e7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -196,6 +196,8 @@ module Users
protocol.archived_by = new_owner unless protocol.archived_by.nil?
protocol.restored_by = new_owner unless protocol.restored_by.nil?
protocol.save!
protocol.user_assignments.find_by(user: new_owner)&.destroy!
protocol.user_assignments.create!(user: new_owner, user_role: UserRole.find_predefined_owner_role)
end
# Make new owner author of all inventory items that were added