fix: clear bot owner on handoff
This commit is contained in:
@@ -165,6 +165,7 @@ class Conversation < ApplicationRecord
|
||||
|
||||
def bot_handoff!
|
||||
update(waiting_since: Time.current) if waiting_since.blank?
|
||||
self.assignee_agent_bot = nil
|
||||
open!
|
||||
dispatcher_dispatch(CONVERSATION_BOT_HANDOFF)
|
||||
end
|
||||
|
||||
@@ -347,6 +347,14 @@ RSpec.describe Conversation do
|
||||
expect(conversation.reload.status).to eq('open')
|
||||
end
|
||||
|
||||
it 'clears agent bot ownership' do
|
||||
conversation.update!(assignee_agent_bot: create(:agent_bot, account: conversation.account))
|
||||
|
||||
conversation.bot_handoff!
|
||||
|
||||
expect(conversation.reload.assignee_agent_bot).to be_nil
|
||||
end
|
||||
|
||||
it 'dispatches CONVERSATION_BOT_HANDOFF event' do
|
||||
expect(Rails.configuration.dispatcher).to receive(:dispatch)
|
||||
.with(described_class::CONVERSATION_BOT_HANDOFF, anything, hash_including(conversation: conversation))
|
||||
|
||||
Reference in New Issue
Block a user