fix: preserve closed status on bot assignment

This commit is contained in:
Sojan Jose
2026-06-26 16:11:08 -07:00
parent ffa9e45d70
commit 50b373c151
2 changed files with 9 additions and 1 deletions
@@ -27,7 +27,7 @@ class Conversations::AssignmentService
conversation.assignee = nil
conversation.assignee_agent_bot = agent_bot
conversation.status = :pending
conversation.status = :pending if conversation.open?
conversation.save!
agent_bot
end
@@ -65,6 +65,14 @@ describe Conversations::AssignmentService do
expect(conversation.assignee_id).to be_nil
expect(conversation.status).to eq('pending')
end
it 'preserves status when assigning an agent bot to a closed conversation' do
conversation.update!(assignee: agent, assignee_agent_bot: nil, status: :resolved)
service.perform
expect(conversation.reload.status).to eq('resolved')
end
end
end
end