From f2f57de26435133881161207caebcd0f6ec933ab Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Mon, 26 Jun 2017 15:30:18 +0200 Subject: [PATCH] Fix changing protocol ownership logic when removing user from the team [SCI-1415] --- app/models/user_team.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user_team.rb b/app/models/user_team.rb index ddbb0fc21..3356fecb5 100644 --- a/app/models/user_team.rb +++ b/app/models/user_team.rb @@ -59,8 +59,8 @@ class UserTeam < ActiveRecord::Base end # Also, make new owner author of all protocols that belong - # to the departing user. - p_ids = user.added_protocols.pluck(:id) + # to the departing user and belong to this team. + p_ids = user.added_protocols.where(team: team).pluck(:id) Protocol.find(p_ids).each do |protocol| protocol.record_timestamps = false protocol.added_by = new_owner