diff --git a/app/models/conversation.rb b/app/models/conversation.rb index fb5701765..e21410451 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -296,6 +296,8 @@ class Conversation < ApplicationRecord end def assign_connected_agent_bot + return if assignee_id.present? + self.assignee = nil self.assignee_agent_bot = inbox.agent_bot end diff --git a/spec/models/conversation_spec.rb b/spec/models/conversation_spec.rb index 0e15920eb..153649de2 100644 --- a/spec/models/conversation_spec.rb +++ b/spec/models/conversation_spec.rb @@ -663,6 +663,14 @@ RSpec.describe Conversation do expect(conversation.assignee).to be_nil end + it 'preserves explicit human assignee' do + agent = create(:user, account: bot_inbox.inbox.account) + conversation = create(:conversation, inbox: bot_inbox.inbox, assignee: agent) + + expect(conversation.assignee).to eq(agent) + expect(conversation.assignee_agent_bot).to be_nil + end + context 'with campaigns' do let(:user) { create(:user, account: bot_inbox.inbox.account) }