Fix protocol owner re-assignment when removing a user from a team [SCI-7457]

This commit is contained in:
Oleksii Kriuchykhin 2022-11-18 12:52:30 +01:00
parent 41a7609c3e
commit 69812786ba

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