fix: preserve status on human reassignment
This commit is contained in:
@@ -14,9 +14,10 @@ class Conversations::AssignmentService
|
||||
attr_reader :conversation, :assignee_id, :assignee_type
|
||||
|
||||
def assign_agent
|
||||
agent_bot_owned = conversation.assignee_agent_bot_id.present?
|
||||
conversation.assignee = assignee
|
||||
conversation.assignee_agent_bot = nil
|
||||
conversation.status = :open if assignee
|
||||
conversation.status = :open if assignee && agent_bot_owned && conversation.pending?
|
||||
conversation.save!
|
||||
assignee
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ RSpec.describe 'Conversation Assignment API', type: :request do
|
||||
end
|
||||
|
||||
it 'assigns a user to the conversation' do
|
||||
conversation.update!(status: :pending)
|
||||
conversation.update!(assignee_agent_bot: agent_bot, status: :pending)
|
||||
params = { assignee_id: agent.id }
|
||||
|
||||
post api_v1_account_conversation_assignments_url(account_id: account.id, conversation_id: conversation.display_id),
|
||||
|
||||
@@ -35,6 +35,14 @@ describe Conversations::AssignmentService do
|
||||
expect(conversation.assignee_agent_bot_id).to be_nil
|
||||
expect(conversation.status).to eq('open')
|
||||
end
|
||||
|
||||
it 'preserves status for ordinary human assignment changes' do
|
||||
conversation.update!(assignee_agent_bot: nil, status: :resolved)
|
||||
|
||||
described_class.new(conversation: conversation, assignee_id: agent.id).perform
|
||||
|
||||
expect(conversation.reload.status).to eq('resolved')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when assigning an agent bot' do
|
||||
|
||||
Reference in New Issue
Block a user